Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.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
Javascript React-从子窗体组件更新父状态_Javascript_Reactjs - Fatal编程技术网

Javascript React-从子窗体组件更新父状态

Javascript React-从子窗体组件更新父状态,javascript,reactjs,Javascript,Reactjs,我正在尝试从我的子组件窗体更新我的状态。但是当我按下enter键时,当前状态值为null。我想问题出在我的handlere功能上,但我不知道它是什么 从“React”导入React,{Component}; 从“/logo.svg”导入徽标; 导入“/App.css”; 从“./Form.js”导入表单; 从“react bootstrap”导入{Button}; 类应用程序扩展组件{ 构造器{ 超级作物; this.handler=this.handler.bindthis 此.state=

我正在尝试从我的子组件窗体更新我的状态。但是当我按下enter键时,当前状态值为null。我想问题出在我的handlere功能上,但我不知道它是什么

从“React”导入React,{Component}; 从“/logo.svg”导入徽标; 导入“/App.css”; 从“./Form.js”导入表单; 从“react bootstrap”导入{Button}; 类应用程序扩展组件{ 构造器{ 超级作物; this.handler=this.handler.bindthis 此.state={ 价值:11 } } 把手{ e、 防止违约; 这是我的国家{ 价值:即目标价值 } } 渲染{ 回来 欢迎反应

要开始,请编辑src/App.js并保存以重新加载。

你好 {this.state.value} ; } } 导出默认应用程序 您已经在应用程序中定义了handleChange并将其传递给表单。但不是使用传递的prop函数,而是在表单组件中再次创建一个新函数handleChange。在这两个组件中还声明了值状态。使用handleChange prop函数来处理更改,而不是创建新的更改

<FormControl
    type="text"
    value={this.state.value}
    placeholder="Enter text"
    onChange={this.props.handleChange}
/>