Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.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/8/variables/2.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 使用setState after函数_Javascript_Reactjs_React Native_Setstate - Fatal编程技术网

Javascript 使用setState after函数

Javascript 使用setState after函数,javascript,reactjs,react-native,setstate,Javascript,Reactjs,React Native,Setstate,我尝试使用react中的setStateafter函数,第一次运行函数,运行后函数finishedsetState({example1'}),我该如何做 单击按钮run loaded Variable withthis.setState({loaded:false}),我将在运行时之后执行函数setStatethis.setState({loaded:true}),如何使用技术完成,我将使用其他代码 container=()=>{return(Balabla)}//在2.select之后完成 t

我尝试使用react中的
setState
after函数,第一次运行函数,运行后函数finished
setState({example1'})
,我该如何做

单击按钮run loaded Variable with
this.setState({loaded:false})
,我将在运行时之后执行函数setState
this.setState({loaded:true})
,如何使用技术完成,我将使用其他代码

  • container=()=>{return(Balabla)}//在2.select之后完成
  • this.setState({loaded:true})
  • 导出默认类搜索扩展React.Component{
    建造师(道具){
    超级(道具);
    此.state={
    加载:正确
    }
    }
    render(){
    返回(
    {this.container()}
    )}
    }
    
    如果我没说错的话,你可能是自找麻烦。您需要一个
    事件处理程序
    onClick
    此处)来调用更改状态的相应函数。此外,如果您的函数是无参数函数,则在调用它时不应使用
    react
    中的
    ()

    container = () => { this.setState({loaded:true})}
    
    render(){
     return(
      <Loader loaded={this.state.loaded} onClick={this.container}/>
     )}
    
    container=()=>{this.setState({loaded:true})}
    render(){
    返回(
    )}
    
    请改进问题中使用的语法。你到底想说什么?你的SETTSTE()在哪里?它在容器()内吗?你需要一个点击事件还是什么?我不明白你在问什么。我也看不出您在代码中是如何使用setState的。我所看到的只是一个构造函数和一个render方法。责任很简单,我将在运行时之后执行函数setstate,我将返回到容器函数所在的位置?container=()=>{return(Balabla)}我用container回调return使用google translate正确叙述您的版本,然后返回。你的判词太可怕了!首先我将运行函数并编写函数的内容(return(blablabla)),然后我将设置另一个变量,为什么您不明白
    container = () => { this.setState({loaded:true})}
    
    render(){
     return(
      <Loader loaded={this.state.loaded} onClick={this.container}/>
     )}