Skip to content

Instantly share code, notes, and snippets.

@hieptlccc
Created January 9, 2022 08:47
Show Gist options
  • Save hieptlccc/f62245c143cefbc77ca1437c319e801f to your computer and use it in GitHub Desktop.
Save hieptlccc/f62245c143cefbc77ca1437c319e801f to your computer and use it in GitHub Desktop.
meeting.js - higher-order component - webex clone
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