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

'children' missing in props validation #574

Closed
noahtallen opened this issue Jul 23, 2016 · 8 comments

Comments

@noahtallen
Copy link

commented Jul 23, 2016

So I reviewed a few of the other issues I saw related to getting this error, but I'm not sure why the issue still persists for me after adding:

propTypes: {
  children: React.PropTypes.node
}

Here's my code:

.\Components\MainLayout1.jsx

import React, { Component } from 'react'
import Navbar from './Navbar.jsx'

// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
import injectTapEventPlugin from 'react-tap-event-plugin'
injectTapEventPlugin()

export default class MainLayout extends Component {
  propTypes: {
    children: React.PropTypes.node
  }
  render () {
    return (
      <div>
        <Navbar />
          <div>{this.props.children}</div> // The error occurs here.
          {/* Put a footer here */}
      </div>
    )
  }
}

However, if I change it to this, the error goes away:

.\components\MainLayout2.jsx

import React, { Component } from 'react'
import Navbar from './Navbar.jsx'

// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
import injectTapEventPlugin from 'react-tap-event-plugin'
injectTapEventPlugin()

class MainLayout extends Component {
  render () {
    return (
      <div>
        <Navbar />
          <div>{this.props.children}</div>
          {/* Put a footer here */}
      </div>
    )
  }
}

MainLayout.propTypes = {
  children: React.PropTypes.node
}

export default MainLayout

Why does the second method work, while the first does not?

@feross feross added the question label Jul 23, 2016

@feross

This comment has been minimized.

Copy link
Member

commented Jul 23, 2016

It looks like you're using an old version of standard. The latest version is 7.1.2. Can you update to the latest version?

npm install standard@latest --save-dev

Or if you have it installed globally:

npm install -g standard

@feross feross closed this Jul 23, 2016

@noahtallen

This comment has been minimized.

Copy link
Author

commented Jul 23, 2016

I tried a global install of standard run on that specific file and there were no issues. I'm still getting the issue inside Atom, however. (7.1.2 is installed locally as well.) Should I make an issue for linter-js-standard?

@feross

This comment has been minimized.

Copy link
Member

commented Jul 23, 2016

There's an issue on linter-js-standard about this: ricardofbarros/linter-js-standard#124

But according to a comment from the maintainer @ricardofbarros, it sounds like if you're using the latest version of linter-js-standard then your local version of standard should be used instead of the version they're shipping.

Can you ensure you're using the latest version of linter-js-standard?

@noahtallen

This comment has been minimized.

Copy link
Author

commented Jul 23, 2016

Standard is specified in my package.json as "standard": "^7.1.2" since I just set up the project today.. I ran the install standard@latest command again but it doesn't look as if anything changed. Also running linter-js-standard v3.4.1 so that looks fine.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 23, 2016

@ntomallen This sounds like it's either a bug in linter-js-standard, or you still have an old version of standard somewhere that's getting used.

@noahtallen

This comment has been minimized.

Copy link
Author

commented Jul 25, 2016

@feross It could be an issue with my installation, but since I installed it for the first time two days ago, I don't think there would be any old standard installations. I'm guessing linter-js-standard, but I'll try to replicate it on a different machine before creating an issue over there.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 25, 2016

@ntomallen Sorry you're having trouble getting this to work. Best of luck figuring it out!

@noahtallen

This comment has been minimized.

Copy link
Author

commented Jul 25, 2016

No worries!

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.