redux-middleware-routing
Created with CodeSandbox
This is a syntax writing practice of
- redux
- redux toolkit
- configuring store using {configureStore}
- creating slices using {createSlice}
- creating reducer
- using the states using {useSelector}
- dispatching actions into the reducer using {useDispatch}
- creating router
- providing paths to all the the pages using {createBrowserRouter}
- providing links to all the pages using {Link}
- providing outlet for the children pages using {Outlet}
- making routes available to all the pages by using {RouterProvider}
- making store available to all the webpages by wrapping the index.js using {Provider}
- creating thunks manually so that they enter middleware instead of reducer.
Note :
This uses the react-router-dom v6.10
so the concepts of {BrowserRouter, Routes, Route, Redirect} does not work in this version.
there is also no concept of {Switch} which you see in many tutorials. It is very old concept in v6.
Feature :
If you still want to do by the method of you should use the createRoutesFromElements