条件无法对本地生产做出反应,但可以在开发中起作用 [英] Condition fails in react native production, but works in development

查看:35
本文介绍了条件无法对本地生产做出反应,但可以在开发中起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个react native应用程序,通过它我需要进行迄今为止的比较.而且,如果为真,将执行执行.

I have created a react native app, by which I need compare from and to date. And if it's true, execution will be done.

问题是,该条件在React本机开发模式下起作用,而在React本机生产版本中不起作用.我正在为数据库使用firebase,也正在使用redux.

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.

这是我的代码:

  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)

需要验证的条件是:

if(d.getDate() >= k.getDate() === true && d.getDate() <= j.getDate() === true){...some code}else{this.props.error("Code Expired")}

这在开发过程中确实可以正常工作,但条件是失败了,并转移到其他地方.我不知道为什么表格和截止日期已从Firebase停用.

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.

请帮助我解决.

推荐答案

实际上,发生这种情况的原因是JavaScript内核不同.作为,chrome具有最新版的core,但没有本地响应.因此,您需要根据ES6给出日期,将日期"01-02-2019"更改为

Actually this, happens because of different javascript core. As , chrome has latest version of core, but react native doesnt. So you need to give date as per ES6, change the date "01-02-2019" to

"Fri Feb 02 2018 00:00:00 GMT+0530 (India Standard Time)". 

然后,删除

.split("-").reverse(); on both dates.

希望完全可以.

这篇关于条件无法对本地生产做出反应,但可以在开发中起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆