Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3405971
D3451.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D3451.diff
View Options
diff --git a/web/splash/splash.react.js b/web/splash/splash.react.js
--- a/web/splash/splash.react.js
+++ b/web/splash/splash.react.js
@@ -6,36 +6,24 @@
import { useModalContext } from '../modals/modal-provider.react';
import css from './splash.css';
-type Props = {
- +setModal: (modal: React.Node) => void,
- +modal: ?React.Node,
-};
-class Splash extends React.PureComponent<Props> {
- render() {
- return (
- <React.Fragment>
- <div onClick={this.onClickLogIn} className={css.loginContainer}>
- <h1>Log in</h1>
- </div>
- {this.props.modal}
- </React.Fragment>
- );
- }
+function Splash(): React.Node {
+ const modalContext = useModalContext();
+ const onClickLogIn = React.useCallback(
+ (event: SyntheticEvent<HTMLElement>) => {
+ event.preventDefault();
+ modalContext.setModal(<LogInModal />);
+ },
+ [modalContext],
+ );
- onClickLogIn = (event: SyntheticEvent<HTMLAnchorElement>) => {
- event.preventDefault();
- this.props.setModal(<LogInModal />);
- };
+ return (
+ <React.Fragment>
+ <div onClick={onClickLogIn} className={css.loginContainer}>
+ <h1>Log in</h1>
+ </div>
+ {modalContext.modal}
+ </React.Fragment>
+ );
}
-const ConnectedSplash: React.ComponentType<{}> = React.memo<{}>(
- function ConnectedSplash(): React.Node {
- const modalContext = useModalContext();
-
- return (
- <Splash setModal={modalContext.setModal} modal={modalContext.modal} />
- );
- },
-);
-
-export default ConnectedSplash;
+export default Splash;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 4, 11:57 PM (12 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2615199
Default Alt Text
D3451.diff (1 KB)
Attached To
Mode
D3451: [web] Turn `Splash` into a functional component
Attached
Detach File
Event Timeline
Log In to Comment