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

Usage with Gatsby #171

Open
radenkovic opened this issue Mar 26, 2021 · 2 comments
Open

Usage with Gatsby #171

radenkovic opened this issue Mar 26, 2021 · 2 comments

Comments

@radenkovic
Copy link

Hi folks, this is very nice library for doing grid!

Just wanted to help to other people who are trying to set up with gatsby:

To add custom configuration you need 2 files:

  1. gatsby-browser.js
import { setConfiguration } from 'react-grid-system';
// Here we configure grid
setConfiguration({ maxScreenClass: 'xl', defaultScreenClass: 'xl' });
  1. gatsby-ssr.js
const { setConfiguration } = require('react-grid-system');

exports.onPreRenderHTML = () => {
  // Here we configure grid
  setConfiguration({ maxScreenClass: 'xl', defaultScreenClass: 'xl' });
};
  1. Also you need to wrap all components in <ScreenClassProvider /> so pages look exactly the same and layout does not get re-rendered after initial hydration.

I think this can be documented in examples or in README.md but took me some time to set it up.

If there are any questions feel free to ask!

@sephi-dev
Copy link

I'm looking to a similar solution for NextJS. I guess we have the same issue here.

@radenkovic
Copy link
Author

@davidvenin same solution should technically work for NextJS (though I did not test). in getInitialProps do the same thing as I did in gatsby-ssr.js and it should do the trick.

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

No branches or pull requests

2 participants