Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.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 redux 通过react redux操作负载传递输入值?_React Redux - Fatal编程技术网

React redux 通过react redux操作负载传递输入值?

React redux 通过react redux操作负载传递输入值?,react-redux,React Redux,基本上,当输入发生更改时,我想调用onSearchTermChange操作并将输入值传递给减速机,但我不知道如何从onSearchTermChange操作访问输入值。您必须使用event.target.value 你的减速机呢 const mapDispatchToProps = dispatch => { return { onSearchTermChange: (value) => dispatch({ type: "SEARCHTERMC

基本上,当输入发生更改时,我想调用onSearchTermChange操作并将输入值传递给减速机,但我不知道如何从onSearchTermChange操作访问输入值。

您必须使用event.target.value

你的减速机呢

const mapDispatchToProps = dispatch => {
  return {
    onSearchTermChange: (value) =>
      dispatch({
        type: "SEARCHTERMCHANGE",
        payLoad: value
      })
  };
};
最后,您需要将您的价值导入到道具中

case "SEARCHTERMCHANGE":
  return {
    ...state,
    value: action.payLoad
  }
const mapDispatchToProps = dispatch => {
  return {
    onSearchTermChange: (value) =>
      dispatch({
        type: "SEARCHTERMCHANGE",
        payLoad: value
      })
  };
};
case "SEARCHTERMCHANGE":
  return {
    ...state,
    value: action.payLoad
  }
const mapStateToProps = (state) => ({
   value: state.value,
})