Redux is a JavaScript framework for managing state in an application
Redux follows one direction flow of data.
It starts in the view.View means the item on a screen that a user sees.
If a user clicks a button or types something in. This is called an action.
When an action happens we need to make sure to change what is displayed to the user.
That action is dispatched through a reducer function.
The reducer must receive the action object and based on that it will figure out what to change and how to make that change. This is how the state management works in Redux.
The reducer then pass new object back to the store.
The store holds the state. It then updates the state and gives it to the view to update.
Flow of PingPong Action
Create a pingPongActionConstant.js file in actionConstants.js then export the constant Variables to this file. Variables are must be in Upper_case and value is same as variable name. Variable names are unique.
Next select the index.js file in actionConstants.js and add
export * from './pingPongActionConstant';
Create a file in action and give name as pingPongAction.js. In this file first import the Variables from './actionConstants' then export the action using arrow function syntax to dispatch the type to debugger.
In this program initialState of both Ping and Pong set to false.
Select rootReducer.js file. Add
import pingPongReducer from './pingPongReducer'
And also add state to store
pingPong:pingPongReducer,
Creating logic in which when we CALL_PING_ACTION dispatch in debugger then action type is set to CALL_PING_ACTION. And in state at the pingPong(pin) ping:True and pong:False.
Create PingPongButton into components/Home folder.