同步显示同步React

问题描述 投票:0回答:0

我有一个组件回调,它返回应立即显示的值 我想在回调执行后立即更新 {zutaten} 我该怎么做?

       
      <div className="bg-blue-500 p-4 m-4 w-1/4 h-80"> 
      <div>
   {zutaten}
    </div>```

The Callback is so:

``` const callback = payload => {
      setState(payload)
      
      State(JSON.stringify(state.wert))
      console.log(state)
  }```

```const [state, setState] = useState([]);```
    ```var [zutaten, State] = useState([]);```
reactjs callback
© www.soinside.com 2019 - 2024. All rights reserved.