react-native-sk-countdown icon indicating copy to clipboard operation
react-native-sk-countdown copied to clipboard

不兼容 React Native 0.30.0

Open huanglong-zz opened this issue 8 years ago • 6 comments

暂时先 hack 了一些代码:

import React, {Component} from 'react';
var ReactNative = require('react-native');

var {
  StyleSheet,
  Text,
} = ReactNative;

如果同时兼容 RN 0.22 又要兼容 0.30 的话,是不是可以通过

if (!React.createClass) React = require('react').react

来替代呢

huanglong-zz avatar Jul 28 '16 08:07 huanglong-zz

改造支持0.30需要独立安装‘react-addons-update’模块

npm i react-addons-update --save

然后改成下面这样:

import React,{Component} from 'react';
import {
    StyleSheet,
    Text, 
} from 'react-native';
import update from 'react-addons-update';
// var update = React.addons.update,
var countDown = require('./countDown');

Infiee avatar Nov 08 '16 15:11 Infiee

@Infiee I try to install react-addons-update and my react-native version is 0.39.2,react version is 15.4.1,react-addons-update version is 15.4.2.But no use, the error tip is Seems you're trying to access 'ReactNative.createClass' from the 'react-native'package.Perhaps you meant to access 'React.creactClass' from the 'react' package instead?

superZchen0701 avatar Jan 14 '17 02:01 superZchen0701

@GeorgeCodesigner show you code

Through the story of my experiments, I don't recommend you to use 3.9/3.8 version, you can try to use the 3.7 is a relatively good version, version 3.9 of the grammar closer to 4.0 forced the es6 standard grammar, suggest wait a few months to try more version 3.9 +, many current didn't keep up with the plugin updates

Woodswu avatar Jan 15 '17 13:01 Woodswu

@Woodswu My codes follow this: var ReactNative=require('react-native'); var React=require('react'); var Text=ReactNative.Text; and so on; var {CountDownText} = require('react-native-sk-countdown'); var Login=React.createClass({ <CountDownText style={styles.countBtn} countType='seconds' // 计时类型:seconds / date auto={true} // 自动开始 afterEnd={this._countingDone} // 结束回调 timeLeft={60} // 正向计时 时间起点为0秒 step={-1} // 计时步长,以秒为单位,正数则为正计时,负数为倒计时 startText='获取验证码' // 开始的文本 endText='获取验证码' // 结束的文本 intervalText={(sec) => '剩余秒数:'+sec} // 定时的文本回调 /> })

superZchen0701 avatar Jan 15 '17 13:01 superZchen0701

@GeorgeCodesigner you need change node_module/react-native-sk-countdown/CountDownText.js, code example:

// old code.............................
// var React = require('react-native');

// var {
//   StyleSheet,
//   Text,
// } = React;

// var React = require('react');
// var {
//     StyleSheet,
//     Text, 
// } = require('react-native');
// var update = React.addons.update,

// new code.............................
import React,{Component} from 'react';
import {
    StyleSheet,
    Text, 
} from 'react-native';
import update from 'react-addons-update';
var countDown = require('./countDown');
...

Infiee avatar Jan 17 '17 09:01 Infiee

@Infiee Thanks a lot! I have solve the problem.

superZchen0701 avatar Jan 17 '17 11:01 superZchen0701