Created
January 9, 2022 08:47
-
-
Save hieptlccc/f62245c143cefbc77ca1437c319e801f to your computer and use it in GitHub Desktop.
meeting.js - higher-order component - webex clone
This file contains 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
import { useContext } from 'react'; | |
import { useHistory } from 'react-router'; | |
import Context from '../../context'; | |
import { saveDataToLocalStorage, navigate } from '../../services/common'; | |
const withMeeting = WrapperComponent => { | |
return function (props) { | |
const { setMeeting } = useContext(Context); | |
const push = useHistory().push; | |
const saveAndJoinMeeting = (meeting) => { | |
saveDataToLocalStorage({ key: 'meeting', payload: JSON.stringify(meeting) }); | |
setMeeting(meeting); | |
navigate({ route: '/meeting', push }); | |
}; | |
return ( | |
<> | |
<WrapperComponent saveAndJoinMeeting={saveAndJoinMeeting} {...props} /> | |
</> | |
) | |
} | |
} | |
export default withMeeting; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment