[英]Condition fails in react native production, but works in development
I have created a react native app, by which I need compare from and to date.我创建了一个 React Native 应用程序,我需要通过它进行比较。 And if it's true, execution will be done.
如果是真的,就会执行。
The problem is, the condition works in react native development mode and not working in react native production release.问题是,该条件适用于本机开发模式,而不适用于本机生产版本。 I am using firebase for the database, also using redux.
我正在为数据库使用 firebase,也使用 redux。
Here is my code:这是我的代码:
var d = new Date();
const fromDate = extract.validFrom.split("-").reverse(); //"01-02-2019"
const tillDate = extract.validTill.split("-").reverse(); //"10-03-2019"
var k = new Date(fromDate)
var j = new Date(tillDate)
The condition need to verified is :需要验证的条件是:
if(d.getDate() >= k.getDate() === true && d.getDate() <= j.getDate() === true){...some code}else{this.props.error("Code Expired")}
This works, absolutely fine while in development, but the condition is failing and moving to else.这有效,在开发过程中绝对没问题,但条件失败并转向其他。 I don't know why.
我不知道为什么。 The form and till date is retired from firebase.
表格和截止日期已从 firebase 中淘汰。
Please help me to solve.请帮我解决。
Actually this, happens because of different javascript core.实际上,这是由于不同的 javascript 核心而发生的。 As , chrome has latest version of core, but react native doesnt.
由于,chrome 具有最新版本的核心,但 react native 没有。 So you need to give date as per ES6, change the date "01-02-2019" to
所以你需要根据 ES6 给出日期,将日期“01-02-2019”更改为
"Fri Feb 02 2018 00:00:00 GMT+0530 (India Standard Time)".
And after that, remove在那之后,删除
.split("-").reverse(); on both dates.
Hope Fully it will work.希望完全它会起作用。
Once I come across the same issue with date.一旦我遇到与日期相同的问题。 Then I have tried to enclose the value with
new Date()
and that helped me.然后我尝试用
new Date()
将值括起来,这对我有帮助。 I thought your problem is also similar to that.我认为你的问题也与此类似。 Try to compare as
尝试比较为
if((new Date(d) >= new Date(k)) && (new Date(d) <= new Date(j))){
...some code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.