diff --git a/web/calendar/day.react.js b/web/calendar/day.react.js --- a/web/calendar/day.react.js +++ b/web/calendar/day.react.js @@ -217,12 +217,7 @@ createNewEntry = (threadID: string) => { if (!this.props.loggedIn) { - this.props.setModal( - , - ); + this.props.setModal(); return; } const viewerID = this.props.viewerID; diff --git a/web/calendar/entry.react.js b/web/calendar/entry.react.js --- a/web/calendar/entry.react.js +++ b/web/calendar/entry.react.js @@ -258,12 +258,7 @@ onChange: (event: SyntheticEvent) => void = event => { if (!this.props.loggedIn) { - this.props.setModal( - , - ); + this.props.setModal(); return; } const target = event.target; @@ -406,12 +401,7 @@ onDelete: (event: SyntheticEvent) => void = event => { event.preventDefault(); if (!this.props.loggedIn) { - this.props.setModal( - , - ); + this.props.setModal(); return; } this.dispatchDelete(this.props.entryInfo.id, true); diff --git a/web/modals/account/log-in-first-modal.react.js b/web/modals/account/log-in-first-modal.react.js --- a/web/modals/account/log-in-first-modal.react.js +++ b/web/modals/account/log-in-first-modal.react.js @@ -1,44 +1,44 @@ // @flow +import invariant from 'invariant'; import * as React from 'react'; +import { ModalContext } from '../../modals/modal-provider.react'; import css from '../../style.css'; import Modal from '../modal.react'; import LogInModal from './log-in-modal.react'; type Props = { +inOrderTo: string, - +setModal: (modal: ?React.Node) => void, }; -class LogInFirstModal extends React.PureComponent { - render(): React.Node { - return ( - - - - {`In order to ${this.props.inOrderTo}, you'll first need to `} - - log in - - {'.'} - - - - ); - } +function LogInFirstModal(props: Props): React.Node { + const modalContext = React.useContext(ModalContext); + invariant(modalContext, 'ModalContext not found'); - clearModal: () => void = () => { - this.props.setModal(null); - }; - - onClickLogIn: (event: SyntheticEvent) => void = event => { + const onClickLogIn: ( + event: SyntheticEvent, + ) => void = event => { event.preventDefault(); - this.props.setModal(); + modalContext.setModal(); }; + + return ( + + + + {`In order to ${props.inOrderTo}, you'll first need to `} + + log in + + {'.'} + + + + ); } export default LogInFirstModal;
- {`In order to ${this.props.inOrderTo}, you'll first need to `} - - log in - - {'.'} -
+ {`In order to ${props.inOrderTo}, you'll first need to `} + + log in + + {'.'} +