Skip to content

Instantly share code, notes, and snippets.

@jasonleehodges
Created October 19, 2019 21:38
Show Gist options
  • Save jasonleehodges/5589996488282d83a4d80110f10b15e0 to your computer and use it in GitHub Desktop.
Save jasonleehodges/5589996488282d83a4d80110f10b15e0 to your computer and use it in GitHub Desktop.
Connected component simplified with custom react-redux hooks
import React, { FunctionComponent } from 'react';
import { useUserState, useUserDispatch } from '../../hooks/user';
export const Navigation: FunctionComponent = () => {
const { user } = useUserState();
const { setUser } = useUserDispatch();
return (
<div className={styles.Navigation} onClick={ setUser('me') }>
User name: { user }
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment