Reputation: 391
I am new to the concepts in Redux and simply: I am wondering how best to pass data from parent to child components.
I see a few approaches.
Here are the pros and cons I see of the approaches I tried.
Method 1:
Method 2:
I haven't really experimented with contexts yet. I was wondering what the Redux way is of doing this. Personally I prefer #2 but the last con is a killer for me. If #3 is better please let me know. Thank you for your help.
Upvotes: 1
Views: 80
Reputation: 31495
Use redux-toolkit.
Create your store, state slices and their reducers using createSlice
from @reduxjs/toolkit
and every component can access the necessary data from store by using useSelector
from react-redux
.
There is no need for mapDispatchToProps
anymore.
Upvotes: 1