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

this is undefined in production but not dev mode #284

Closed
sotojuan opened this issue Jul 29, 2016 · 4 comments
Closed

this is undefined in production but not dev mode #284

sotojuan opened this issue Jul 29, 2016 · 4 comments

Comments

@sotojuan
Copy link

We have an app that we ported over to this CLI tool and it works perfectly in development mode. However, if we run the build folder in a server (using pushstate-server) we get:

Uncaught TypeError: Cannot read property 'props' of undefined

The component is simple:

class AuthLayout extends React.Component {
  render() {
    return (
      <div id="auth-layout">
        <div id="auth-content">
          <this.props.views.content />
        </div>
      </div>
    )
  }
}

Like I said, this works great in dev mode. Why not in production?

@gaearon
Copy link
Contributor

gaearon commented Jul 29, 2016

This might be a bug in babel-plugin-transform-react-constant-elements.
Can you comment it out in react-scripts/config/babel.prod.js and see if that fixes it?
If it does, we should file a bug against Babel.

@gaearon
Copy link
Contributor

gaearon commented Jul 29, 2016

(Temporary fix is likely to write var Content = this.props.view.content and then use <Content /> instead.)

@insin
Copy link
Contributor

insin commented Jul 29, 2016

It's a bug with the transform: https://phabricator.babeljs.io/T7494

@sotojuan
Copy link
Author

@gaearon Yup, that was it. If I remove it, it works! Closing.

@lock lock bot locked and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants