Skip to content

getDefaultProps not working #3655

Closed
@meetwudi

Description

@meetwudi

I am working on a very simple component with default props.

// React component
class Navigation extends React.Component {
  getDefaultProps() {
    return {
      user: {a:1}
    }
  }

  render() {
    console.log(this.props);
    if (this.props.user) {
      // User has been logged in
      return (
        ...
      );
    }
    else {
      // User not logged in
      return (
        ...
      );
    }
  }
}

Navigation.propTypes = {
  user: React.PropTypes.object
};

return Navigation;

And I simply render it without any props (<Navigation />). But I got an empty object from console output.

I am using react 0.13.1, chrome 41, OSX 10.10.

Any idea what is going wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions