gpt4 book ai didi

react-native - React Native Redux - 对象不是构造函数(评估 'new ctor(props context)' )

转载 作者:行者123 更新时间:2023-12-04 11:17:19 26 4
gpt4 key购买 nike

这是一个尝试使用 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);

最佳答案

重置缓存对我有用:

react-native start --reset-cache

其他解决方案是使用 createSwitchNavigator相反 createStackNavigator , 在您的导航器容器中。

关于react-native - React Native Redux - 对象不是构造函数(评估 'new ctor(props context)' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60471786/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com