Reactjs 使用Material UI Modal进行反应-将所有Modal放入应用程序中,但如何从应用程序访问Redux商店?
我将PersonSelectReact组件放入Material UI modal()中: 因此,通过Reactjs 使用Material UI Modal进行反应-将所有Modal放入应用程序中,但如何从应用程序访问Redux商店?,reactjs,react-redux,material-ui,modal-dialog,store,Reactjs,React Redux,Material Ui,Modal Dialog,Store,我将PersonSelectReact组件放入Material UI modal()中: 因此,通过connect和mapStateToProps实现该机制: const mapStateToProps = state => { return { openPersonSelectModal: state.openPersonSelectModal, }; }; 使我们有机会在对话框中使用(Redux控制和更新的)属性this.props.openPerso
connect
和mapStateToProps
实现该机制:
const mapStateToProps = state => {
return {
openPersonSelectModal: state.openPersonSelectModal,
};
};
使我们有机会在
对话框中使用(Redux控制和更新的)属性this.props.openPersonSelectModal
:
<Modal
open={this.props.openPersonSelectModal}
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description"
>
<PersonSelect></PersonSelect>
</Modal>
但是我们没有用于应用程序组件的应用程序和ConnectedApp
因此,我的问题是:
保留在
中
访问Redux存储/状态属性以将其放入
我很清楚,从UIX的角度来看,情态动词的使用是不好的。我不是在这里讨论这个问题。我只是将模态工作流作为替代方案来实现,因为一些用户仍然使用模态,仍然需要模态,并且仍然希望模态在这里为他们提供。我现在考虑完全避免使用材质UI模态。React Boostrap和Material UI modals只是非常薄的层,基本上只是添加/删除一些CSS类(用于模态样式)。通常,我可以继续使用我自己的PersonSelect组件,并在这里添加分支逻辑——是否应用模态样式,是否呈现组件JSX代码。我可以让人选择显示为模态对话框或参数化的常用SPA页面。我看不出MaterialUI模态组件可以增加多少价值。它只是添加或删除样式。
const mapStateToProps = state => {
return {
openPersonSelectModal: state.openPersonSelectModal,
};
};
<Modal
open={this.props.openPersonSelectModal}
aria-labelledby="simple-modal-title"
aria-describedby="simple-modal-description"
>
<PersonSelect></PersonSelect>
</Modal>