Skip to content

Include contents as argument in popstate event #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

lencioni
Copy link
Contributor

At Causes, we are using pjax in conjunction with Reactjs. As we have
currently implemented things, when using the back and forward buttons
(popstate), the following warning is logged:

React attempted to use reuse markup in a container but the checksum
was invalid. This generally means that you are using server rendering
and the markup generated on the server was not what the client was
expecting. React injected new markup to compensate which works but you
have lost many of the benefits of server rendering. Instead, figure
out why the markup being generated is different on the client or
server.

To prevent this message from happening, we need a way to clean out the
markup that was generated by React components before putting them back
on the page. It seems like an event handler that listens to the
pjax:popstate event is a reasonable place to do this, but the page's
contents are not sent along with that event.

This commit includes the contents that will end up on the page when
popping state in the pjax:popstate event that is triggered. This will
enable us to clean out the bits that are not desired before they hit the
page.

At Causes, we are using pjax in conjunction with Reactjs. As we have
currently implemented things, when using the back and forward buttons
(popstate), the following warning is logged:

> React attempted to use reuse markup in a container but the checksum
> was invalid. This generally means that you are using server rendering
> and the markup generated on the server was not what the client was
> expecting. React injected new markup to compensate which works but you
> have lost many of the benefits of server rendering. Instead, figure
> out why the markup being generated is different on the client or
> server.

To prevent this message from happening, we need a way to clean out the
markup that was generated by React components before putting them back
on the page. It seems like an event handler that listens to the
pjax:popstate event is a reasonable place to do this, but the page's
contents are not sent along with that event.

This commit includes the contents that will end up on the page when
popping state in the pjax:popstate event that is triggered. This will
enable us to clean out the bits that are not desired before they hit the
page.
@mislav
Copy link
Collaborator

mislav commented Jun 17, 2014

Would the recent pjax:beforeReplace event be good enough for you? We're even improving it further in #403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants