how can i dispatch store and override initial props in nextjsHow to pass props to this.props.childrenHow to get simple dispatch from this.props using connect w/ Redux?How to dispatch a Redux action with a timeout?Understanding React-Redux and mapStateToProps()redux-thunk dispatch method fires undefined actionHow to pass props to redux store from a Rails 5 viewsRedux - mapDispatchToProps - TypeError: _this.props.setCurrentUserHandle is not a functionunable to use applyMiddleWare in reduxRedux createStore/applyMiddleWare Q
How to display numbers like 10,000.42 using siunitx?
crippling fear of hellfire &, damnation, please help?
Took GRE two times, same scores with minor differences - worth sending both?
Boss wants me to ignore a software API license prohibiting mass download
Does fossil fuels use since 1990 account for half of all the fossil fuels used in history?
Can sampling rate be a floating point number?
Is there a SQL/English like language that lets you define formulations given some data?
Is it okay for a ticket seller to grab a tip in the USA?
Does the rule that you cannot willingly end your move in another creature's space force or prevent certain actions?
Do beef farmed pastures net remove carbon emissions?
Are 变 and 変 the same?
Why is statically linking glibc discouraged?
Graphs for which a calculus student can reasonably compute the arclength
Why aren't rainbows blurred-out into nothing after they are produced?
What is the farthest a camera can see?
80's/90's superhero cartoon with a man on fire and a man who made ice runways like Frozone
Why does the standard fingering / strumming for a D maj chord leave out the 5th string?
Website error: "Walmart can’t use this browser"
How far did Gandalf and the Balrog drop from the bridge in Moria?
Is this n-speak?
Are employers legally allowed to pay employees in goods and services equal to or greater than the minimum wage?
Why did I get only 5 points even though I won?
Why command hierarchy, if the chain of command is standing next to each other?
Help, I cannot decide when to start the story
how can i dispatch store and override initial props in nextjs
How to pass props to this.props.childrenHow to get simple dispatch from this.props using connect w/ Redux?How to dispatch a Redux action with a timeout?Understanding React-Redux and mapStateToProps()redux-thunk dispatch method fires undefined actionHow to pass props to redux store from a Rails 5 viewsRedux - mapDispatchToProps - TypeError: _this.props.setCurrentUserHandle is not a functionunable to use applyMiddleWare in reduxRedux createStore/applyMiddleWare Q
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to call API inside getInitialProps then save that response in redux store.so how can I call dispatch store and override initial props
right now after fetching data from API, I'm able to dispatch value to the reducer and it also saving data in store but after saving data my app calling for initial props(i don't know from where it changes the states) and overriding my new saved data into initial props.
main.js
class StepThree extends React.Component
static async getInitialProps( reduxStore, req )
let encID = req.query.id //null
try
let encode = await encrption(encID,7,'dec')
const apiCall = await fetch(`$config.leadSearchApi&search_param=$encode`);
let res = await apiCall.json();
if(res.data['next_action'] !== "converted")
let test = await reduxStore.dispatch( type: PATIENT_NAME,payload:res.data.name );
console.log(test,'res');
await reduxStore.dispatch( type: PATIENT_NUMBER,payload:res.data['mobile_number'] );
await reduxStore.dispatch( type: LEAD_ID,payload:res.data.id );
catch (err)
console.log(err,'get err');
return
render()
return <div>Hello World </div>
const mapStateToProps = (state, prevProps) =>
return
AmbSelect:state.StepThreeReducer.isAmbSel,
Addons:state.StepThreeReducer.addonSel,
VehcileData:state.StepThreeReducer.vehcileData,
TotalPrice:state.StepThreeReducer.totalPrice,
Cameback:state.StepThreeReducer.comeback,
LeadID:state.Main.LeadId
export default connect(mapStateToProps,addOnSelected,priceCal,updateLeadS3,previous,VehicleDataHandler,updateVehData, addonsCount,totalPrice,existLeadData,linkLead2,linkLead3,encrption )(StepThree);
App.js
import App, Container from 'next/app'
import React from 'react'
import withReduxStore from '../lib/with-redux-store'
import Provider from 'react-redux'
class MyApp extends App
render ()
const Component, pageProps, reduxStore = this.props;
return (
<Container>
<Provider store=reduxStore>
<Component ...pageProps />
</Provider>
</Container>
)
export default withReduxStore(MyApp)
redux-store.js
import React from 'react'
import initializeStore from '../store'
const isServer = typeof window === 'undefined'
const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__'
function getOrCreateStore (initialState)
// Always make a new store if server, otherwise state is shared between requests
if (isServer)
return initializeStore(initialState)
// Create store if unavailable on the client and set it on the window object
if (!window[__NEXT_REDUX_STORE__])
window[__NEXT_REDUX_STORE__] = initializeStore(initialState)
return window[__NEXT_REDUX_STORE__]
export default App =>
return class AppWithRedux extends React.Component
static async getInitialProps (appContext)
// Get or Create the store with `undefined` as initialState
// This allows you to set a custom default initialState
const reduxStore = getOrCreateStore()
// Provide the store to getInitialProps of pages
appContext.ctx.reduxStore = reduxStore
let appProps =
if (typeof App.getInitialProps === 'function')
appProps = await App.getInitialProps(appContext)
return
...appProps,
initialReduxState: reduxStore.getState()
constructor (props)
super(props)
this.reduxStore = getOrCreateStore(props.initialReduxState)
render ()
return <App ...this.props reduxStore=this.reduxStore />
store.js
import createStore, applyMiddleware,combineReducers from 'redux'
import composeWithDevTools from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
import './actions';
import reducer from './reducers'
export function initializeStore ()
return createStore(
reducer,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
reducer.js
import PATIENT_NAME,PATIENT_NUMBER,RIDE_DATE,RIDE_TIME,FCAUSES,SETCAUSE from '../actions/types';
const INITIAL_STATE =
patient_name:'',
patient_number:'',
ride_date:false,
ride_time:false,
causes:,
sel_cause:''
;
export default (state=INITIAL_STATE,action) =>
console.log(action,'reducer')
switch(action.type)
case PATIENT_NAME:
return ...state,patient_name:action.payload;
case PATIENT_NUMBER:
return ...state,patient_number:action.payload;
case RIDE_DATE:
return ...state,ride_date:action.payload;
case RIDE_TIME:
return ...state,ride_time:action.payload;
case FCAUSES:
return ...state,causes:action.payload;
case SETCAUSE:
return ...state,sel_cause:action.payload;
default:
return state;

after dispatch I don't want to make app state as initial props
please help,stuckkkkkk
reactjs redux redux-thunk next.js
add a comment |
I want to call API inside getInitialProps then save that response in redux store.so how can I call dispatch store and override initial props
right now after fetching data from API, I'm able to dispatch value to the reducer and it also saving data in store but after saving data my app calling for initial props(i don't know from where it changes the states) and overriding my new saved data into initial props.
main.js
class StepThree extends React.Component
static async getInitialProps( reduxStore, req )
let encID = req.query.id //null
try
let encode = await encrption(encID,7,'dec')
const apiCall = await fetch(`$config.leadSearchApi&search_param=$encode`);
let res = await apiCall.json();
if(res.data['next_action'] !== "converted")
let test = await reduxStore.dispatch( type: PATIENT_NAME,payload:res.data.name );
console.log(test,'res');
await reduxStore.dispatch( type: PATIENT_NUMBER,payload:res.data['mobile_number'] );
await reduxStore.dispatch( type: LEAD_ID,payload:res.data.id );
catch (err)
console.log(err,'get err');
return
render()
return <div>Hello World </div>
const mapStateToProps = (state, prevProps) =>
return
AmbSelect:state.StepThreeReducer.isAmbSel,
Addons:state.StepThreeReducer.addonSel,
VehcileData:state.StepThreeReducer.vehcileData,
TotalPrice:state.StepThreeReducer.totalPrice,
Cameback:state.StepThreeReducer.comeback,
LeadID:state.Main.LeadId
export default connect(mapStateToProps,addOnSelected,priceCal,updateLeadS3,previous,VehicleDataHandler,updateVehData, addonsCount,totalPrice,existLeadData,linkLead2,linkLead3,encrption )(StepThree);
App.js
import App, Container from 'next/app'
import React from 'react'
import withReduxStore from '../lib/with-redux-store'
import Provider from 'react-redux'
class MyApp extends App
render ()
const Component, pageProps, reduxStore = this.props;
return (
<Container>
<Provider store=reduxStore>
<Component ...pageProps />
</Provider>
</Container>
)
export default withReduxStore(MyApp)
redux-store.js
import React from 'react'
import initializeStore from '../store'
const isServer = typeof window === 'undefined'
const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__'
function getOrCreateStore (initialState)
// Always make a new store if server, otherwise state is shared between requests
if (isServer)
return initializeStore(initialState)
// Create store if unavailable on the client and set it on the window object
if (!window[__NEXT_REDUX_STORE__])
window[__NEXT_REDUX_STORE__] = initializeStore(initialState)
return window[__NEXT_REDUX_STORE__]
export default App =>
return class AppWithRedux extends React.Component
static async getInitialProps (appContext)
// Get or Create the store with `undefined` as initialState
// This allows you to set a custom default initialState
const reduxStore = getOrCreateStore()
// Provide the store to getInitialProps of pages
appContext.ctx.reduxStore = reduxStore
let appProps =
if (typeof App.getInitialProps === 'function')
appProps = await App.getInitialProps(appContext)
return
...appProps,
initialReduxState: reduxStore.getState()
constructor (props)
super(props)
this.reduxStore = getOrCreateStore(props.initialReduxState)
render ()
return <App ...this.props reduxStore=this.reduxStore />
store.js
import createStore, applyMiddleware,combineReducers from 'redux'
import composeWithDevTools from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
import './actions';
import reducer from './reducers'
export function initializeStore ()
return createStore(
reducer,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
reducer.js
import PATIENT_NAME,PATIENT_NUMBER,RIDE_DATE,RIDE_TIME,FCAUSES,SETCAUSE from '../actions/types';
const INITIAL_STATE =
patient_name:'',
patient_number:'',
ride_date:false,
ride_time:false,
causes:,
sel_cause:''
;
export default (state=INITIAL_STATE,action) =>
console.log(action,'reducer')
switch(action.type)
case PATIENT_NAME:
return ...state,patient_name:action.payload;
case PATIENT_NUMBER:
return ...state,patient_number:action.payload;
case RIDE_DATE:
return ...state,ride_date:action.payload;
case RIDE_TIME:
return ...state,ride_time:action.payload;
case FCAUSES:
return ...state,causes:action.payload;
case SETCAUSE:
return ...state,sel_cause:action.payload;
default:
return state;

after dispatch I don't want to make app state as initial props
please help,stuckkkkkk
reactjs redux redux-thunk next.js
please show your reducer's code
– Kort
Mar 27 at 10:22
@Kort updated, plz recheck
– Abdulla Zulqarnain
Mar 27 at 10:27
Seems all ok. Have you checked you reduxDevTools? Only from there you can figure out what happened.
– Kort
Mar 27 at 10:33
@Kort now u can see in the image, after saving data again it calling initial state
– Abdulla Zulqarnain
Mar 27 at 10:36
add a comment |
I want to call API inside getInitialProps then save that response in redux store.so how can I call dispatch store and override initial props
right now after fetching data from API, I'm able to dispatch value to the reducer and it also saving data in store but after saving data my app calling for initial props(i don't know from where it changes the states) and overriding my new saved data into initial props.
main.js
class StepThree extends React.Component
static async getInitialProps( reduxStore, req )
let encID = req.query.id //null
try
let encode = await encrption(encID,7,'dec')
const apiCall = await fetch(`$config.leadSearchApi&search_param=$encode`);
let res = await apiCall.json();
if(res.data['next_action'] !== "converted")
let test = await reduxStore.dispatch( type: PATIENT_NAME,payload:res.data.name );
console.log(test,'res');
await reduxStore.dispatch( type: PATIENT_NUMBER,payload:res.data['mobile_number'] );
await reduxStore.dispatch( type: LEAD_ID,payload:res.data.id );
catch (err)
console.log(err,'get err');
return
render()
return <div>Hello World </div>
const mapStateToProps = (state, prevProps) =>
return
AmbSelect:state.StepThreeReducer.isAmbSel,
Addons:state.StepThreeReducer.addonSel,
VehcileData:state.StepThreeReducer.vehcileData,
TotalPrice:state.StepThreeReducer.totalPrice,
Cameback:state.StepThreeReducer.comeback,
LeadID:state.Main.LeadId
export default connect(mapStateToProps,addOnSelected,priceCal,updateLeadS3,previous,VehicleDataHandler,updateVehData, addonsCount,totalPrice,existLeadData,linkLead2,linkLead3,encrption )(StepThree);
App.js
import App, Container from 'next/app'
import React from 'react'
import withReduxStore from '../lib/with-redux-store'
import Provider from 'react-redux'
class MyApp extends App
render ()
const Component, pageProps, reduxStore = this.props;
return (
<Container>
<Provider store=reduxStore>
<Component ...pageProps />
</Provider>
</Container>
)
export default withReduxStore(MyApp)
redux-store.js
import React from 'react'
import initializeStore from '../store'
const isServer = typeof window === 'undefined'
const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__'
function getOrCreateStore (initialState)
// Always make a new store if server, otherwise state is shared between requests
if (isServer)
return initializeStore(initialState)
// Create store if unavailable on the client and set it on the window object
if (!window[__NEXT_REDUX_STORE__])
window[__NEXT_REDUX_STORE__] = initializeStore(initialState)
return window[__NEXT_REDUX_STORE__]
export default App =>
return class AppWithRedux extends React.Component
static async getInitialProps (appContext)
// Get or Create the store with `undefined` as initialState
// This allows you to set a custom default initialState
const reduxStore = getOrCreateStore()
// Provide the store to getInitialProps of pages
appContext.ctx.reduxStore = reduxStore
let appProps =
if (typeof App.getInitialProps === 'function')
appProps = await App.getInitialProps(appContext)
return
...appProps,
initialReduxState: reduxStore.getState()
constructor (props)
super(props)
this.reduxStore = getOrCreateStore(props.initialReduxState)
render ()
return <App ...this.props reduxStore=this.reduxStore />
store.js
import createStore, applyMiddleware,combineReducers from 'redux'
import composeWithDevTools from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
import './actions';
import reducer from './reducers'
export function initializeStore ()
return createStore(
reducer,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
reducer.js
import PATIENT_NAME,PATIENT_NUMBER,RIDE_DATE,RIDE_TIME,FCAUSES,SETCAUSE from '../actions/types';
const INITIAL_STATE =
patient_name:'',
patient_number:'',
ride_date:false,
ride_time:false,
causes:,
sel_cause:''
;
export default (state=INITIAL_STATE,action) =>
console.log(action,'reducer')
switch(action.type)
case PATIENT_NAME:
return ...state,patient_name:action.payload;
case PATIENT_NUMBER:
return ...state,patient_number:action.payload;
case RIDE_DATE:
return ...state,ride_date:action.payload;
case RIDE_TIME:
return ...state,ride_time:action.payload;
case FCAUSES:
return ...state,causes:action.payload;
case SETCAUSE:
return ...state,sel_cause:action.payload;
default:
return state;

after dispatch I don't want to make app state as initial props
please help,stuckkkkkk
reactjs redux redux-thunk next.js
I want to call API inside getInitialProps then save that response in redux store.so how can I call dispatch store and override initial props
right now after fetching data from API, I'm able to dispatch value to the reducer and it also saving data in store but after saving data my app calling for initial props(i don't know from where it changes the states) and overriding my new saved data into initial props.
main.js
class StepThree extends React.Component
static async getInitialProps( reduxStore, req )
let encID = req.query.id //null
try
let encode = await encrption(encID,7,'dec')
const apiCall = await fetch(`$config.leadSearchApi&search_param=$encode`);
let res = await apiCall.json();
if(res.data['next_action'] !== "converted")
let test = await reduxStore.dispatch( type: PATIENT_NAME,payload:res.data.name );
console.log(test,'res');
await reduxStore.dispatch( type: PATIENT_NUMBER,payload:res.data['mobile_number'] );
await reduxStore.dispatch( type: LEAD_ID,payload:res.data.id );
catch (err)
console.log(err,'get err');
return
render()
return <div>Hello World </div>
const mapStateToProps = (state, prevProps) =>
return
AmbSelect:state.StepThreeReducer.isAmbSel,
Addons:state.StepThreeReducer.addonSel,
VehcileData:state.StepThreeReducer.vehcileData,
TotalPrice:state.StepThreeReducer.totalPrice,
Cameback:state.StepThreeReducer.comeback,
LeadID:state.Main.LeadId
export default connect(mapStateToProps,addOnSelected,priceCal,updateLeadS3,previous,VehicleDataHandler,updateVehData, addonsCount,totalPrice,existLeadData,linkLead2,linkLead3,encrption )(StepThree);
App.js
import App, Container from 'next/app'
import React from 'react'
import withReduxStore from '../lib/with-redux-store'
import Provider from 'react-redux'
class MyApp extends App
render ()
const Component, pageProps, reduxStore = this.props;
return (
<Container>
<Provider store=reduxStore>
<Component ...pageProps />
</Provider>
</Container>
)
export default withReduxStore(MyApp)
redux-store.js
import React from 'react'
import initializeStore from '../store'
const isServer = typeof window === 'undefined'
const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__'
function getOrCreateStore (initialState)
// Always make a new store if server, otherwise state is shared between requests
if (isServer)
return initializeStore(initialState)
// Create store if unavailable on the client and set it on the window object
if (!window[__NEXT_REDUX_STORE__])
window[__NEXT_REDUX_STORE__] = initializeStore(initialState)
return window[__NEXT_REDUX_STORE__]
export default App =>
return class AppWithRedux extends React.Component
static async getInitialProps (appContext)
// Get or Create the store with `undefined` as initialState
// This allows you to set a custom default initialState
const reduxStore = getOrCreateStore()
// Provide the store to getInitialProps of pages
appContext.ctx.reduxStore = reduxStore
let appProps =
if (typeof App.getInitialProps === 'function')
appProps = await App.getInitialProps(appContext)
return
...appProps,
initialReduxState: reduxStore.getState()
constructor (props)
super(props)
this.reduxStore = getOrCreateStore(props.initialReduxState)
render ()
return <App ...this.props reduxStore=this.reduxStore />
store.js
import createStore, applyMiddleware,combineReducers from 'redux'
import composeWithDevTools from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
import './actions';
import reducer from './reducers'
export function initializeStore ()
return createStore(
reducer,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
reducer.js
import PATIENT_NAME,PATIENT_NUMBER,RIDE_DATE,RIDE_TIME,FCAUSES,SETCAUSE from '../actions/types';
const INITIAL_STATE =
patient_name:'',
patient_number:'',
ride_date:false,
ride_time:false,
causes:,
sel_cause:''
;
export default (state=INITIAL_STATE,action) =>
console.log(action,'reducer')
switch(action.type)
case PATIENT_NAME:
return ...state,patient_name:action.payload;
case PATIENT_NUMBER:
return ...state,patient_number:action.payload;
case RIDE_DATE:
return ...state,ride_date:action.payload;
case RIDE_TIME:
return ...state,ride_time:action.payload;
case FCAUSES:
return ...state,causes:action.payload;
case SETCAUSE:
return ...state,sel_cause:action.payload;
default:
return state;

after dispatch I don't want to make app state as initial props
please help,stuckkkkkk
reactjs redux redux-thunk next.js
reactjs redux redux-thunk next.js
edited Mar 27 at 10:35
Abdulla Zulqarnain
asked Mar 27 at 10:15
Abdulla ZulqarnainAbdulla Zulqarnain
1211 silver badge11 bronze badges
1211 silver badge11 bronze badges
please show your reducer's code
– Kort
Mar 27 at 10:22
@Kort updated, plz recheck
– Abdulla Zulqarnain
Mar 27 at 10:27
Seems all ok. Have you checked you reduxDevTools? Only from there you can figure out what happened.
– Kort
Mar 27 at 10:33
@Kort now u can see in the image, after saving data again it calling initial state
– Abdulla Zulqarnain
Mar 27 at 10:36
add a comment |
please show your reducer's code
– Kort
Mar 27 at 10:22
@Kort updated, plz recheck
– Abdulla Zulqarnain
Mar 27 at 10:27
Seems all ok. Have you checked you reduxDevTools? Only from there you can figure out what happened.
– Kort
Mar 27 at 10:33
@Kort now u can see in the image, after saving data again it calling initial state
– Abdulla Zulqarnain
Mar 27 at 10:36
please show your reducer's code
– Kort
Mar 27 at 10:22
please show your reducer's code
– Kort
Mar 27 at 10:22
@Kort updated, plz recheck
– Abdulla Zulqarnain
Mar 27 at 10:27
@Kort updated, plz recheck
– Abdulla Zulqarnain
Mar 27 at 10:27
Seems all ok. Have you checked you reduxDevTools? Only from there you can figure out what happened.
– Kort
Mar 27 at 10:33
Seems all ok. Have you checked you reduxDevTools? Only from there you can figure out what happened.
– Kort
Mar 27 at 10:33
@Kort now u can see in the image, after saving data again it calling initial state
– Abdulla Zulqarnain
Mar 27 at 10:36
@Kort now u can see in the image, after saving data again it calling initial state
– Abdulla Zulqarnain
Mar 27 at 10:36
add a comment |
1 Answer
1
active
oldest
votes
You did't provide an initialState into initializeStore when you creating your store.
To make sure that you're using the same state shape across server and client pass the initialState params to you store initialization inside store.js:
export function initializeStore(initialState = )
return createStore(
reducer,
initialState,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
Otherwise same state will always be applied and server-propagated state will be lost.
yeh, solved by myself but forgot to put the answer.thanks alot
– Abdulla Zulqarnain
Mar 27 at 11:39
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55374727%2fhow-can-i-dispatch-store-and-override-initial-props-in-nextjs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You did't provide an initialState into initializeStore when you creating your store.
To make sure that you're using the same state shape across server and client pass the initialState params to you store initialization inside store.js:
export function initializeStore(initialState = )
return createStore(
reducer,
initialState,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
Otherwise same state will always be applied and server-propagated state will be lost.
yeh, solved by myself but forgot to put the answer.thanks alot
– Abdulla Zulqarnain
Mar 27 at 11:39
add a comment |
You did't provide an initialState into initializeStore when you creating your store.
To make sure that you're using the same state shape across server and client pass the initialState params to you store initialization inside store.js:
export function initializeStore(initialState = )
return createStore(
reducer,
initialState,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
Otherwise same state will always be applied and server-propagated state will be lost.
yeh, solved by myself but forgot to put the answer.thanks alot
– Abdulla Zulqarnain
Mar 27 at 11:39
add a comment |
You did't provide an initialState into initializeStore when you creating your store.
To make sure that you're using the same state shape across server and client pass the initialState params to you store initialization inside store.js:
export function initializeStore(initialState = )
return createStore(
reducer,
initialState,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
Otherwise same state will always be applied and server-propagated state will be lost.
You did't provide an initialState into initializeStore when you creating your store.
To make sure that you're using the same state shape across server and client pass the initialState params to you store initialization inside store.js:
export function initializeStore(initialState = )
return createStore(
reducer,
initialState,
composeWithDevTools(applyMiddleware(thunkMiddleware))
)
Otherwise same state will always be applied and server-propagated state will be lost.
answered Mar 27 at 10:48
KortKort
1387 bronze badges
1387 bronze badges
yeh, solved by myself but forgot to put the answer.thanks alot
– Abdulla Zulqarnain
Mar 27 at 11:39
add a comment |
yeh, solved by myself but forgot to put the answer.thanks alot
– Abdulla Zulqarnain
Mar 27 at 11:39
yeh, solved by myself but forgot to put the answer.thanks alot
– Abdulla Zulqarnain
Mar 27 at 11:39
yeh, solved by myself but forgot to put the answer.thanks alot
– Abdulla Zulqarnain
Mar 27 at 11:39
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55374727%2fhow-can-i-dispatch-store-and-override-initial-props-in-nextjs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
please show your reducer's code
– Kort
Mar 27 at 10:22
@Kort updated, plz recheck
– Abdulla Zulqarnain
Mar 27 at 10:27
Seems all ok. Have you checked you reduxDevTools? Only from there you can figure out what happened.
– Kort
Mar 27 at 10:33
@Kort now u can see in the image, after saving data again it calling initial state
– Abdulla Zulqarnain
Mar 27 at 10:36