Why am I getting this warning `No duplicate props allowed react/jsx-no-duplicate-props`
You probably passed the same prop twice to a Component. e.g. <MyComponent someProp={‘a’} someProp={‘b’} />
You probably passed the same prop twice to a Component. e.g. <MyComponent someProp={‘a’} someProp={‘b’} />
unfortunately, selector function accepts only store’s state as argument. I would consider to use a currying approach to tackle the issue: export const getProductNameById = id => store => { return store.dashboard.dashboards.filter(({ Id }) => Id === id)[0] .Name; } some file import { useSelector } from “react-redux”; import { getProductNameById } from “./selectors”; const … Read more
I faced the same issue, for me it was just solved by adding AppDispatch to the type of useDispatch hook; const dispatch = useDispatch<AppDispatch>(); useEffect(() => { dispatch(getUsers()); }, []); getUsers() was my createAsyncThunk function
Redux Thunk teaches Redux to recognize special kinds of actions that are in fact functions. When an action creator returns a function, that function will get executed by the Redux Thunk middleware. This function doesn’t need to be pure; it is thus allowed to have side effects, including executing asynchronous API calls. The function can … Read more
This reminds me of how I started one of my projects where the data was highly relational. You think too much still about the backend way of doing things, but you gotta start thinking of more of the JS way of doing things (a scary thought for some, to be sure). 1) Normalized Data in … Read more
You need to replace withRef with forwardRef as per the release notes: The withRef option to connect has been replaced with forwardRef. If {forwardRef : true} has been passed to connect, adding a ref to the connected wrapper component will actually return the instance of the wrapped component. So in your case: export default connect( … Read more
Import creatBrowserHistory with curly brackets. It’s exported as a named export. // history.js import { createBrowserHistory } from “history”; export default createBrowserHistory(); Then import and use it in index. // index.js import history from “./history”; import { Provider } from “react-redux”; import store from “./store/store”; const AppContainer = () => ( <Router history={history}> <Provider store={store}> … Read more
Off the top of my head, a few advantages: A lot of the time your app’s state tree could be considerably different than the UI tree Many components may need to access the same state and display it in different ways Hot reloading components will wipe out your existing component tree, including any state stored … Read more
As @Ying Zuo said, your method works only with Functional Components. To solve this problem: Instead of this line: const counter = useSelector(state => state.counter); You define the counter state like this: const mapStateToProps = state => ({ counter: state.counter }); Then for dispatching you should use it like this: const mapDispatchToProps = () => … Read more
According to the docs you are mixing up the usage of redux-logger You either need to import the specific createLogger function import { createLogger } from ‘redux-logger’ const logger = createLogger({ // …options }); Or use the default import import logger from ‘redux-logger’ And then your code should be fine const store = createStore( reducers, … Read more