Skip to content

Instantly share code, notes, and snippets.

@jasonleehodges
Created March 21, 2020 22:38
Show Gist options
  • Save jasonleehodges/69f8737a862eeb9c3ac7288b033c0e57 to your computer and use it in GitHub Desktop.
Save jasonleehodges/69f8737a862eeb9c3ac7288b033c0e57 to your computer and use it in GitHub Desktop.
Using Data Service Custom Hook
import React, { FC } from 'react';
import { useDataSErvice } from '../hooks';
import { useSelector } from 'react-redux';
import { selectData } from '../selectors';
export const ExampleComponent: FC = (props) => {
const { getData } = useDataService();
const data = useSelector(selectData);
useEffect(() => {
getData();
}, []);
return (
<div>{ data }</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment