Skip to content

carstenjlund/redux-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demoing some Redux

This project was bootstrapped with Create React App, using the Redux and Redux Toolkit template.

UsersSlice

The usersSlice fetches 10 users from the jsonplaceholder api with a thunk and stores them in the usersstore. The usersSlice has a createUser thunk to, well, create a user!. I dispathc the fetchUser thunk from the app component, to make the state available to both the Users and AddUser components.

Users component

Gets the users from state and displays them in a list.

Add user component

Uses react-hook-form to add a user. The user is posted to the api, and the api response is added to the users state. Adding more than one user, will result in a warning in the console, since users are not really added to the api, any new user will return te same id (and I use the id's as keys when listing the users).

About

Practicing redux

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •