Skip to content

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,
  };

  /* ... */
}

@taion taion added the feature-request Used to close PRs that haven't gone through/been accepted the Proposal process yet label Mar 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Used to close PRs that haven't gone through/been accepted the Proposal process yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants