以编程方式关闭模态(反应物化)

Closing the modal programmatically (react-materialize)

我不知道如何以编程方式关闭模式(例如,用户登录后的登录模式)。

看起来像这样:

<Modal
  actions={[
    <Button flat modal="close" node="button" waves="green">
      Close
    </Button>
  ]}
  bottomSheet={false}
  fixedFooter={false}
  header="Log in"
  id="modal-login"
  options={{
    dismissible: true,
    endingTop: "10%",
    inDuration: 250,
    onCloseEnd: null,
    onCloseStart: null,
    onOpenEnd: null,
    onOpenStart: null,
    opacity: 0.5,
    outDuration: 250,
    preventScrolling: true,
    startingTop: "4%"
  }}
>
  <form onSubmit={e => /* log in user */}>
    <input type="email"/>
    <input type="password"/>
    <button>Log in</button>
  </form>
</Modal>

使用 open 属性以编程方式打开或关闭模式

<Modal
  open={isModalOpen}
  ...
/>

参考:https://react-materialize.github.io/react-materialize/?path=/story/javascript-modal--default