jam*_*phy 14 react-native react-redux
这是一个尝试使用 Redux 的非常简单的页面……请参阅下面的代码。
但是我收到错误 object is not a constructor (evaluating 'new ctor(props context)')
import React, {Component} from 'react';
import {Text, View} from 'react-native';
import {connect} from 'react-redux';
const mapStateToProps = state => ({
userId: state.auth.userId,
});
class Message extends Component {
render() {
return (
<View>
<Text>Text here</Text>
</View>
);
}
}
export default connect(
mapStateToProps,
null,
)(Message);
Run Code Online (Sandbox Code Playgroud)
小智 31
重置缓存对我有用:
react-native start --reset-cache
Run Code Online (Sandbox Code Playgroud)
其他的解决办法是使用createSwitchNavigator,而不是createStackNavigator在你的导航器容器。
| 归档时间: |
|
| 查看次数: |
10299 次 |
| 最近记录: |