在处理函数中,更新这样的浮力,
handleClick() { this.progressBar.update( <ProgressBar /> ); }
和进度键组件,
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { View } from 'react-native';
const getFinishedWidth = progress => ({ width: progress * totalWidth });
const getUnfinishedWidth = progress => ({ width: (1 - progress) * totalWidth });
function CustomerReassignProgressBar(props) {
const { progress } = props;
return (
<View style={styles.bar}>
<View style={getFinishedWidth(progress)} />
<View style={getUnfinishedWidth(progress)} />
</View> );
}
CustomerReassignProgressBar.propTypes = { progress: PropTypes.number, };
const mapStateToProps = state => ({ progress: state.batchReassignProgress, });
export default connect(mapStateToProps)(ProgressBar);
然后,当调用handleclick()时,应用程序被压碎,错误是,'在"连接(progressbar)"的上下文或道具中找不到"存储"。将根组件包裹在a中,或者明确将"存储"作为"连接(progressbar)"的道具。'
如果我不使用Connect组件中的连接,则可以很好地工作。因此,我想,也许Rootsiblings无法与React-Redux使用。但是有人知道这个问题吗?
升级到 react-native-root-siblings@4.x
然后
import { setSiblingWrapper } from 'react-native-root-siblings';
import { Provider } from 'react-redux';
const store = xxx;// get your redux store here
// call this before using any root-siblings related code
setSiblingWrapper(sibling => (
<Provider store={store}>{sibling}</Provider>
));