What you will be building
Please check this link: Rock Paper Scissors Game
This app uses components from Chakra UI . You should check it out.
Reference
We first looked at setClearAll here.
Let’s get going.
actions/set-clear-all.ts
import defaultState from '../state/default-state';
// interfaces
import { SetState } from '../state/interfaces';
interface Payload {
setState: SetState;
}
const setClearAll = (payload: Payload) => {
const { setState } = payload;
setState(defaultState);
};
export default setClearAll;
Our Imports
We need the default state to work with and the types to work with also. These have already been defined here.
And the function?
Well, we want to clear everything. The easiest way to do that is to reset the state completely.
So that is what we do.
Ta da! Job done!