Warm tip: This article is reproduced from serverfault.com, please click

How to implement customReducer in React-Admin

发布于 2020-11-30 10:46:00

I try to implement a customReducer to manage my own custom state in React-Admin. I have looked through the documentation. I can see where to register the reducer in the <Admin>, but I don't see where to really dispatch the reducer to store the state.

I also wish to know how to retrieve my state from the Redux store. What dataProvider is appropriate for this?

Please could someone share a code snippet to do this?

Thanks

Questioner
Olumide Omolayo
Viewed
0
Kia Kaha 2020-11-30 22:33:16

First - reducers are not dispatched - probably you have meant actions.

After adding the customReducer you interact with the store in the usual way any redux store is accessed: throught hooks if functional component useSelector() useDispatch() or through the connect HOC in a class component.