Context provides a way to pass data through the component tree without having to pass props down manually at every level.
We are using context for login methods - Auth0, JWT, Firebase, AWS.
SWR
SWR is a popular library used for data fetching and state management in React applications. Data fetching is covered in Axios API calls section, here we are going to cover about state management using SWR.
Mantis is managing state of following using SWR
Snackbar states
Menu states
E-commerce Cart
1.Snackbar
Snackbar is used to show notification in application. Whenever component dispatch a action with data to show snackbar, it appears in app. The initial state of snackbar is being capture using useSWR hooks and after that, we are mutating it state based on action calls. Following is the initital state:
To read the values and listen, following SWR hooks is sufficient in component. Whenever any changes happen, it activated like redux selector and act based on logic.