Skip to content

Instantly share code, notes, and snippets.

@vldvel
Last active February 7, 2019 06:47
Show Gist options
  • Save vldvel/e94a2ac0e3ab204d17253a9667a64a92 to your computer and use it in GitHub Desktop.
Save vldvel/e94a2ac0e3ab204d17253a9667a64a92 to your computer and use it in GitHub Desktop.
initActions in root
export const initActions = async dispatch => {
let updateTimeout;
updateMessages = async () => {
await dispatch(getNewMessages());
updateTimeout = setTimeout(updateMessages, 500);
}
updateMessages();
}
class App extends React.PureComponent {
componentDidMount() {
this.props.initActions();
}
render() {
return (
<div>
<Header />
<Main />
<Footer />
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment