This is a React redux car application to get practice using Redux essentials
In this activity, you will refactor an application that uses the Context API so that it handles state using the open source JavaScript library Redux.
Copy the src
directory from the Develop
folder into 00-practice-app
before you begin.
-
Begin by installing the
redux
andreact-redux
libraries withnpm
. -
Create a
store.js
file in theutils
directory. This file should do the following:-
Import
{ createStore }
fromredux
. -
Import
reducers
from./reducers
. -
Create a default export of
createStore
that accepts an argument ofreducers
.
-
-
Open
/utils/CarContext.js
and import{ Provider }
fromreact-redux
andstore
from./store
. -
Refactor the
CarProvider
component so that it returns<Provider>
with an attribute ofstore
, set to the value ofstore
. -
Clean up any unused code left over from the React Hooks.
-
Run the application, using
npm run start
, to ensure that functionality is unchanged for the end user.
How can we use the Redux Fundamentals guide to find examples of implementation?
What needs to be changed, if anything, inside the reducers.js
file?
If you have completed this activity, work through the following challenge with your partner to further your knowledge:
- Instead of using
React.createContext
, how can we useRedux.createStore
and the existingreducer
to generate the initial state and to calculate any future updates?
Use Google or another search engine to research this.
ยฉ 2022 edX Boot Camps LLC. Confidential and Proprietary. All Rights Reserved.