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
Post a Comment