我有多种模式用于注册,并且遇到问题。我总共有三个动作。首先注册按钮,然后激活第一个注册模式,以注册谷歌或Facebook,然后完成模式的附加信息,无法由提供商收集将出现预填充输入收集形式提供商。我在呈现应用程序时呈现两种模式,并且只在单击注册按钮时才显示它。我需要在完成Facebook或Google登录后调用componentDidMount,但在应用程序拳头启动时呈现模态时会调用它。这些按钮打击动作减速器和减速器,以改变布尔型的状态以显示模式。为什么我重新渲染时不会调用componentDidMount?
class HeaderRegisterButton extends Component {
render() {
return(
<div>
<Register1/>
<Register2/>
</div>
);
}
}
注册模态1
class Register1 extends Component {
render() {
return(
<div>
<button onClick={() => this.props.showRegister2()} /> //This would hit the action reducer to get initial info and change the bool to show register 1 to false and register 2 to true.
</div>
);
}
}
注册模态2
import { reduxForm, Field, initialize } from 'redux-form';
class Register2 extends Component {
componentDidMount() {
hInitalize() //only called when the app fires, not when the state changes in the action reducer to change bool to show this modal.
}
hInitalize() {
var initData = {};
const initData = {
"name" = this.props.name//name stored inside redux store
};
this.props.initialize(initData)
}
render() {
return(
<div>
//Code to display the modal which works.
</div>
);
}
}
'componentDidMount'只调用一次,而不是每次重新渲染。这将是'componentDidUpdate'。 – Li357
正是我所需要的! – joethemow
@AndrewLi这实际上创建了一个问题,我无法输入任何输入/表格 – joethemow