如何将名称const添加到第二个setState方法中?为了增加currentCompany我必须包括prevState。当我尝试添加名称const时,它不起作用。
const name = company.word;
this.setState({ name });
this.setState(prevState => ({
currentCompany: (prevState.currentCompany + 1)
}));
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助 :)