This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Random number
Dima Vyshniakov edited this page Nov 19, 2022
·
2 revisions
Gets random number from random.org API and saves it to state. ALso saves request loading state.
Returns request loading state from the store.
import {useLoadingState} from 'features/random';
// Needs to be run from inside React component or other hook.
const {isLoading, hasError, isFulfilled} = useLoadingState();
Returns random number value from the store
import {useRandomNumber} from 'features/random';
// Needs to be run from inside React component or other hook.
const number = useRandomNumber();
Performs AJAX query to get random number from random.org. Records number and loading state data to the store;
import {useGetRandomNumberQuery} from 'features/random';
// Needs to be run from inside React component or other hook.
const getNumber = useGetRandomNumberQuery();
const handleClick = () => {
getNumber();
}