next-redux-wrapper TypeError: nextCallback is not a function error in wrapper.getServerSideProps

The signature for the function passed to wrapper.getServerSideProps has changed in next-redux-wrapper v7.x. Replace the following. export const getServerSideProps = wrapper.getServerSideProps(async ({req, store}) => { // Code here }) With the right signature. export const getServerSideProps = wrapper.getServerSideProps((store) => async ({ req }) => { // Code here })

Changing the layout of a component depending on Redux state

connect state on your Child components Using connect on child components has the following advantages: Your parent component need not bother about connecting all the props required by its children even though the parent itself is not using the prop. Child components become more reusable, and easily maintainable. Avoids passing down props blindly from parent … Read more

Use history.push in action creator with react-router-v4?

Instead of using BrowserRouter you could use the Router with custom history like import { Router } from ‘react-router’ import createBrowserHistory from ‘history/createBrowserHistory’ export const history = createBrowserHistory() <Router history={history}> <App/> </Router> in which case your history.push() will work. With BrowserRouter history.push doesn’t work because Creating a new browserHistory won’t work because <BrowserRouter> creates its … Read more

How to trigger off callback after updating state in Redux?

component should be updated to receive new props. there are ways to achieve your goal: 1. componentDidUpdate check if value is changed, then do something.. componentDidUpdate(prevProps){ if(prevProps.value !== this.props.value){ alert(prevProps.value) } } 2. redux-promise ( middleware will dispatch the resolved value of the promise) export const updateState = (key, value)=> Promise.resolve({ type:’UPDATE_STATE’, key, value }) … Read more

TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined raised when starting react app

To fix this issue simply upgrade react-scripts package (check latest version with npm info react-scripts version): Replace in your package.json “react-scripts”: “^3.x.x” with “react-scripts”: “^3.4.1” (or the latest available version) (optional for some) Delete your node_modules folder Run npm install or yarn install Some people reported that this issue was caused by running npm audit … Read more