Created
June 23, 2016 00:24
-
-
Save steida/ab60102ecee2591aec1cb269333af099 to your computer and use it in GitHub Desktop.
React stateless components with lifecycle proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HelloMessage = props => | |
<div>Hello {props.name}</div>; | |
{ | |
let isMounted = false; | |
const focusAfterAfterOneSec = el => { | |
setTimeout(() => { | |
if (!isMounted) return; | |
el.focus(); | |
}, 1000); | |
} | |
HelloMessage.componentDidMount = el => { | |
isMounted = true; | |
focusAfterAfterOneSec(el); | |
}; | |
HelloMessage.componentWillUnmount = el => { | |
isMounted = false; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment