vrizo / uibook

Lightweight tool for React components visual testing with media queries
MIT License
228 stars 6 forks source link

Not work with create-react-app #3

Closed TuxGit closed 5 years ago

TuxGit commented 5 years ago

I try use the uibook with project based on create-react-app. Dev server starts ok, but page /uibook is empty/white. Console is clear (no errors).

My steps:

Versions:

"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"uibook": "^0.5.1"

P.S. sometimes an error occurs webpackHotUpdate is not defined - I think this is not the main problem.

vrizo commented 5 years ago

Hi, @TuxGit!

Thanks for the detailed bug report!

It took some time, but I found a problem. I've tested Uibook with outdated Create React App which uses Webpack 3.x. There are lots of changes in chunk splitting in Webpack 4.x, that's why it was broken. I fixed it in the 0.5.2 version.

Also, there is a limitation with the default Create React App webpack config. It is supposed that there will be an only single bundle, so Uibook can't start. Please refer to the updated troubleshooting page.

Please upgrade and let me know if it works now :)

vrizo commented 5 years ago

Also, here is an example src/button.js which is not included in docs. It might be useful for quick start with CRA:

import React, { Component } from 'react';

class Button extends Component {
  render () {
    return (
      <button
        onClick={ this.props.onClick }
        style={{
          background: '#FF7E79',
          padding: '5px 15px',
          border: 'none'
        }}
      >{ this.props.children }</button>
    );
  }
}

export default Button;
TuxGit commented 5 years ago

@vrizo Thanks, it worked! Today I tested with eject and able to run with a plugin "react-app-rewired" (know this is not the best practice). I hope the tool will be useful in a new project!)

I apologize for the long wait =)

vrizo commented 5 years ago

@TuxGit , Wow, great, I'm glad to hear it! Thank you! Please let me know if you have any questions or suggestions.