LocChat/client/components/home/_home.jsx
2021-11-22 14:21:53 -07:00

24 lines
534 B
JavaScript

import { useContext } from 'react';
import { SettingsContext } from '../../utils/settings_context';
export const Home = () => {
const [, dispatch] = useContext(SettingsContext);
const logout = async () => {
const res = await fetch('/sessions', {
method: 'DELETE',
});
if (res.status === 200) {
dispatch({ type: 'update', payload: { jwt: undefined } });
}
};
return (
<div>
<h1>Welcome</h1>
<button type="button" onClick={logout}>
Logout
</button>
</div>
);
};