Skip to content
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

Add a rehydrate function #677

Open
kof opened this issue Feb 4, 2018 · 2 comments
Open

Add a rehydrate function #677

kof opened this issue Feb 4, 2018 · 2 comments
Labels
complexity:moderate We talked about it, you can do it! feature request This will safe many lifes! important The thing you do when you wake up!

Comments

@kof
Copy link
Member

kof commented Feb 4, 2018

Initially I went against creating a separate rehydrate function, because we decided to not actually do rehydration, but instead just regenerate the styles, because it is fast enough and more robust.

So if I did `jss.rehydrate('.style-selector')´ it would be basically inserting the styles after this element and just removing the old style node.

Now as some people had issues with mismatching selectors from SSR, it makes sense to add some more logic to rehydrate, which will make sure in dev mode that user gets proper error report.

  1. Check that client and server setup uses the same NODE_ENV
  2. Check the module id matches between ssr and client (first part - module id)
    • Check the JSS versions matching between ssr and client
    • if hot reload is used and modules are reevaluated, a mismatch is possible
  3. Check the JSS instances counter matches between ssr and client. (second part - Jss instance id)
  4. If last part is not matching (rule id)
  5. Support streaming (https://github.com/cssinjs/react-jss/issues/203)

All checks could be done for e.g. if ssr generates a comment string which contains the information (dev mode only). Rehydration call checks the comment and prints a warning or error.

@kof kof added idea What if we turn JSS into styled-components? feature request This will safe many lifes! complexity:moderate We talked about it, you can do it! labels Feb 4, 2018
@kof
Copy link
Member Author

kof commented Feb 4, 2018

cc @jedwards1211

@Aetherall
Copy link

Indeed, It could be really usefull to have those error reports. Actually managing packages which uses jss as dependency is a pain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity:moderate We talked about it, you can do it! feature request This will safe many lifes! important The thing you do when you wake up!
Projects
None yet
Development

No branches or pull requests

2 participants