-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
milestone: have broken categories page WIP
- Loading branch information
alex-cannon
committed
Nov 21, 2019
1 parent
7a98ff6
commit 7344f02
Showing
7 changed files
with
75 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface asyncAction { | ||
type: string; | ||
payload: any; | ||
errorMessage: string; | ||
} | ||
|
||
export interface asyncState { | ||
loading: boolean; | ||
errorMessage: string; | ||
data: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useEffect } from "react"; | ||
import { useSelector, useDispatch } from "react-redux"; | ||
import { getAllServices } from "./actions"; | ||
|
||
/** | ||
* Hook to use all services data. Service data is parsed into an object. | ||
* Services object: { loading, errorMessage, data } | ||
*/ | ||
const useServices = () => { | ||
const services = useSelector(state => state.services); | ||
const dispatch = useDispatch(); | ||
|
||
// Equivilent to componentDidMount | ||
useEffect(() => { | ||
if (services.data) return; | ||
dispatch(getAllServices()); | ||
}, []); | ||
|
||
return services; | ||
}; | ||
|
||
export default useServices; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters