File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -6,31 +6,29 @@ import "./styles.css";
66import fetchData from "../../services/api" ;
77
88export const useApi = url => {
9- // TODO: loading, error, data loader from API
10- // TODO: pass the url in so that we call fetchData(url)
11- return {
12- loading,
13- error,
14- data
15- } ;
16- } ;
17-
18- export const Feed = ( ) => {
199 const [ loading , setLoading ] = React . useState ( true ) ;
2010 const [ error , setError ] = React . useState ( null ) ;
2111 const [ data , setData ] = React . useState ( null ) ;
2212
2313 React . useEffect ( ( ) => {
24- fetchData ( "messages" )
14+ fetchData ( url )
2515 . then ( result => {
2616 setData ( result ) ;
2717 setLoading ( false ) ;
2818 } )
2919 . catch ( error => {
3020 setError ( error ) ;
3121 } ) ;
32- } , [ ] ) ;
22+ } , [ url ] ) ;
23+ return {
24+ loading,
25+ error,
26+ data
27+ } ;
28+ } ;
3329
30+ export const Feed = ( ) => {
31+ const { loading, error, data } = useApi ( "messages" ) ;
3432 if ( loading ) {
3533 return (
3634 < div className = "Feed" >
You can’t perform that action at this time.
0 commit comments