Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native React redux数据未成功传递_React Native_Redux_React Redux - Fatal编程技术网

React native React redux数据未成功传递

React native React redux数据未成功传递,react-native,redux,react-redux,React Native,Redux,React Redux,我试图将react数据传递给redux,但似乎没有成功,尽管我编写的代码与教程完全相同 以下是相关功能: 在components/login form.js中 testFunction(text) { console.log("The text entered is: ", text); //this reflects successful text entry this.props.authInputChange({'field': 'email', 'value:': tex

我试图将react数据传递给redux,但似乎没有成功,尽管我编写的代码与教程完全相同

以下是相关功能:

在components/login form.js中

testFunction(text) {
    console.log("The text entered is: ", text); //this reflects successful text entry
    this.props.authInputChange({'field': 'email', 'value:': text});
  }

const mapStateToProps = state => {
  console.log("The state is: ", state); //this does not get updated

  return {
    email: state.auth.email,
    password: state.auth.password
  }
};

export default connect(mapStateToProps, { authInputChange, login })(LoginForm);
export const authInputChange = ({ field, value }) => {
    console.log("The value entered is: ", value); //this value is empty
    return {
        type: 'AUTH_INPUT_CHANGE',
        payload: { field, value }
    };
}
在actions/index.js中

testFunction(text) {
    console.log("The text entered is: ", text); //this reflects successful text entry
    this.props.authInputChange({'field': 'email', 'value:': text});
  }

const mapStateToProps = state => {
  console.log("The state is: ", state); //this does not get updated

  return {
    email: state.auth.email,
    password: state.auth.password
  }
};

export default connect(mapStateToProps, { authInputChange, login })(LoginForm);
export const authInputChange = ({ field, value }) => {
    console.log("The value entered is: ", value); //this value is empty
    return {
        type: 'AUTH_INPUT_CHANGE',
        payload: { field, value }
    };
}
现在,尽管我完全按照教程进行了学习(除了我自己添加的console.log语句),但我怀疑讲师犯了错误,这就是为什么有些东西没有通过应该通过的地方。但我不知道会是什么,因为我在redux是个笨蛋

谢谢你的帮助

查看此行:

authInputChange({'field':'email','value:':text})

您正在设置
值:
等于
文本
而不是
。所以你想要:

authInputChange({'field':'email','value':text})

此外,我假设您的减速器设置正确


旁注:这也是我不喜欢在对象键周围加引号的原因。如果您没有在
值:
周围加引号,您会立即看到此错误

你能给我们一个更完整的场景吗?你有表格吗?你们有减速机吗?减速器安装正确了吗?嘿,伙计,不管你做了多久,每个人都会这样。很乐意帮忙。最好的。