reactjs - Populating state from localstorage in React -


in react + flux based application, make api call fetch data in componentdidmount() function of react component. improve ux, query localstorage see if ui can populated & accordingly update state.

so far, have been making call query localstorage in componentwillmount() function, avoiding render() call due statechange.

but while implementing server side render, react throws error saying "rendered server side html did not match client side render: checksum fail". reason error that, server won't able read localstorage still carry initial state render. client can read localstorage & hence initial render different.

so question community is, there better way achieve this? populate ui using localstorage in initial render rather in 2nd render call & still use server side rendering without causing "checksum fail" error react on client?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -