Created
February 18, 2020 01:55
-
-
Save QQBoxy/ef315364d9f55b14835857d257a34f5d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const defaultState = { | |
| code: null, | |
| data: null, | |
| total: null, | |
| }; | |
| const Regions = ({ ...props }) => { | |
| const [{ code, data }, setState] = useState(defaultState); | |
| useEffect(() => { | |
| let canceled = false; | |
| setState(defaultState); | |
| (async () => { | |
| const { | |
| data: { code, total, data }, | |
| } = await listApi(); | |
| if (canceled) return; | |
| setState({ code, data, total }); | |
| })(); | |
| return () => (canceled = true); | |
| }, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment