question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dev run shows different styling than production build

See original GitHub issue

Are you reporting a bug?

I am trying to build static site using material-ui. Sample is at: https://github.com/paramr/react-static-issue/tree/master . when I run in dev i see styling of UI which disappears when I run in prod. Dev: screen shot 2018-12-20 at 5 14 38 pm

Prod: screen shot 2018-12-20 at 5 14 08 pm

Environment

  1. react-static -V: 6.0.11
  2. node -v: v10.14.2
  3. npm -v: 6.4.1
  4. Operating system: mac OS - 10.14.2
  5. Browser and version (if relevant): Repros on safari and chrome

Steps to Reproduce the problem

I started from archives/old-examples/material-ui and fixed issues that arose to get it working for dev. Repro steps are:

  1. $ git clone https://github.com/paramr/react-static-issue.git
  2. $ cd react-static-issue
  3. $ npm install
  4. $ npm run start
  5. open http://localhost:3000 on browser.
  6. $ non run build-dbg
  7. $ cd dist
  8. $ python3 -m http.server 8080
  9. open http://localhost:8080 on browser

Expected Behavior

Both sites should look the same.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tannerlinsleycommented, Dec 21, 2018

The process of static generation doesn’t happen at dev time, as this would be too costly and slow and just doesn’t make sense for developer experience.

Both renderToElement and renderToHtml are methods that are used only to produce the static HTML for the static site. That HTML is then used as the starting point for the app to rehydrate.

Just as with any static site generation in React, there are side effects of rendering that must be extracted and pushed into the resulting HTML so as to ensure that the HTML markup looks exactly the same as the post-mounted react markup.

These methods provide a place to do that (but I can see how they are a bit confusing), and to be honest, most of this should be happening in plugins that we haven’t built yet.

You can still achieve what you are wanting without a plugin for now though.

This repo has a working static export configuration for matierial UI: https://github.com/cbroberg/react-static-mui

In fact, let’s track this issue there (#896) from here on out.

0reactions
paramrcommented, Dec 21, 2018

Thanks for explanation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: Production build looks different from development build
I had an issue where in production, the setState getting called twice, and somehow it run in parallel. The result rendered was half...
Read more >
CSS Properties of production build are different than local build.
Notice that the source of the styles is different between your local and production builds; when running locally, your styles are injected ...
Read more >
Organizing your CSS - Learn web development | MDN
Does your project have a coding style guide? · Keep it consistent · Formatting readable CSS · Comment your CSS · Create logical...
Read more >
Optimizing Performance - React
If you visit a site with React in development mode, the icon will have a red ... Then, to create a production build,...
Read more >
Creating a Production Build - Create React App
npm run build creates a build directory with a production build of your app. Inside the build/static directory will be your JavaScript and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found