Be A React Dev

Game Action - Set Clear All Rock Paper Scissors

21-Jul-2023


Amazon Prime

typescript plus react

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!


Get Cool Swag

If you are finding this content useful (or maybe you are just a nice person or maybe you just like my merch) I would be greatful if you headed over to my shop and make a purchase or two. All proceeds will go towards making more courses.

If there’s merch missing that you would like, let me know (click this: Make Something For Me ) and I’ll try to make it for you.

Wistful T-Shirt

Wistful T-Shirt

You can buy this product or you can check out my shop of products.


About

The Author Guy

Find Me

Rob Welan <rob.welan@beareact.dev>FacebookKo-FiLinkedInMediumPatreonRSS FeedStack OverflowX

Tech In Use

Be A React Dev

© 2024 Be A React Dev. All rights reserved.