SSR'd React components depending on query not matching client
See original GitHub issueWhen use in conjunction with SSR, it seems that when rendered on the server, the location state object doesn’t container the query. So, a mapStateToProps like:
const mapStateToProps = ({location}) => {
return {
tabActive:
get(location, ['query', 'find'], null) ===
Constants.FIRST_OPTION,
};
};
Gets the checksum react error for server markup not matching client markup, since on the server location.query is not present, yet on the client it is. Is there a proper way to access the query string from the server side rendering pass?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Warning: Text content did not match. Server: "I'm out" Client
This prevents the component from being included on the server, and dynamically loads it on the client-side only. const Home = dynamic( ()...
Read more >What I learned from React-Query, and why I won't use it again
Id of the new section is saved to the store as selectedSectionId (client state); Value of selectedSectionData is derived from the siteSections ...
Read more >Combining Server-Side Rendering and Responsive Design
In this example, the server renders all components despite the breakpoints - so that both “layout” components are part of the rendered markup....
Read more >SSR | TanStack Query Docs
Create a new QueryClient instance inside of your app, and on an instance ref (or in React state). This ensures that data is...
Read more >Server-side rendering - Apollo GraphQL Docs
This prevents Apollo Client from refetching queries unnecessarily, ... your React tree directly to a string (instead of the component-based example below), ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yup, doing
Seems to have done the trick! Cheers.
Exactly. You have to manually recreate /path?query=foo
Look at the history API. I forget but it might also take a location object instead of a string which will be easier for you to provide without string creation.
Also log history.location after you create the history. If it has the query on it, it will work. …crossing my fingers that the history memory package works the same as the browser one.