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

Updated PropTypes #3218

Merged
merged 3 commits into from
Apr 12, 2016
Merged

Updated PropTypes #3218

merged 3 commits into from
Apr 12, 2016

Conversation

timdorr
Copy link
Member

@timdorr timdorr commented Mar 22, 2016

Depending on how #3205 shakes out, this provides updated and correct PropTypes.

@taion
Copy link
Contributor

taion commented Mar 22, 2016

Let's change this up a bit.

I don't think exporting PropTypes as-is from the index is useful. It makes it a bit tricky to actually use the prop types in a straightforward way that avoids naming collisions.

Additionally, many of these prop types don't make sense to export:

  • history is deprecated as a public API point
  • location belongs to the history library
  • component and components are never exposed to users
  • route and routes are set up for internal use rather than external use (e.g. route will never be an element as supplied to a route component)
  • Nobody should be importing falsy as a prop type from React Router

We should do the following:

  • For now, keep exporting PropTypes to avoid breaking the API
  • Going forward, only export the router prop type, and export it at top level as routerShape

That way, I can write my code as:

import { routerShape } from 'react-router';

export default class MyComponent extends React.Component {
  static contextTypes = {
    router: routerShape.isRequired,
  };

  /* ... */
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants