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;








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;




enter image description here



after dispatch I don't want to make app state as initial props

please help,stuckkkkkk










share|improve this question


























  • 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

















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;




enter image description here



after dispatch I don't want to make app state as initial props

please help,stuckkkkkk










share|improve this question


























  • 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













0












0








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;




enter image description here



after dispatch I don't want to make app state as initial props

please help,stuckkkkkk










share|improve this question
















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;




enter image description here



after dispatch I don't want to make app state as initial props

please help,stuckkkkkk







reactjs redux redux-thunk next.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer

























  • yeh, solved by myself but forgot to put the answer.thanks alot

    – Abdulla Zulqarnain
    Mar 27 at 11:39











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
);



);













draft saved

draft discarded


















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









1














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.






share|improve this answer

























  • yeh, solved by myself but forgot to put the answer.thanks alot

    – Abdulla Zulqarnain
    Mar 27 at 11:39
















1














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.






share|improve this answer

























  • yeh, solved by myself but forgot to put the answer.thanks alot

    – Abdulla Zulqarnain
    Mar 27 at 11:39














1












1








1







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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









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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해