我正在学习React + Relay + GraphQL教程@ https://facebook.github.io/relay/docs/tutorial.html
我对于什么接口感到困惑:[nodeInterface]在GraphQL对象定义中做了什么.
单击按钮时,我正在渲染新表单.所以基本上我改变了组件中的状态:
false为true或null为true
但是,奇怪的是,组件在状态更改后不会重新呈现
export default class BoardManager extends React.Component{
constructor(){
super();
this.state = {
newForm : null
};
setTimeout(() => {
this.state = {
newForm : true
};
console.log(this.state.newForm);
},1000);
}
render(){
return(
<div>
Some thing here
{this.state.newForm ? <NewBoardForm />: null}
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
非常感谢!!!
编辑!!!解
export default class BoardManager extends React.Component{
constructor(){
super();
this.state = {
newForm : null
};
}
render(){
return(
<div>
<BoardsTable boards={BoardData.boards}/>
<button onClick={() => {
this.setState({
newForm : true
});
console.log(this.state.newForm);
}}>Add …Run Code Online (Sandbox Code Playgroud)