-
Notifications
You must be signed in to change notification settings - Fork 356
How to depend on this package? #4
Comments
Is there any problem with just using it as a dependency? |
@gaearon perhaps something like the following could be a problem?
context: https://twitter.com/bjrmatos/status/850590087364489216 |
Exactly as @bjrmatos says, it is about optimising the bundle. I like the idea of separating the PropTypes stuff (I personally don't use it in my apps as I have TypeScript), but I am afraid this could lead to duplication of its code across the bundle. What I would like to achieve is this: If the I'm not sure how to do this though (if it is even possible)... |
If everyone puts |
There's no documentation of how to import and use import PropTypes from 'prop-types' (Sorry if this is the wrong place for this comment.)
|
Apologies for that. We released on Friday in a hurry and missed some issues like this. We will add documentation soon but for now please see examples in our blog: https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html |
@gaearon is it possible to write library that uses PropTypes in a manner that it is compatible with both e.g. React |
i think that putting from the React 15.5 blog post:
the important part is "This will enable future code size optimizations.".. i think that in the end there will be no code size optimizations at least for apps (for the source of React, sure) if there is easy way that the code of but i think this is something that can be solved with education, maybe a section in the README of this package and in the React's docs (prop types section) could help?. Considering that |
I totally see (and agree with) your point. I don't think "future optimizations" referred to PropTypes specifically. You are right it doesn't enable any optimizations, and in bad cases can make the issue worse. I think @acdlite was referring to We could've split We're going to discuss this with the team more on Monday. |
thnk you, i'm sure there will be something to do to tackle this problem, your solution seems the best to me but let's see. 😄 |
Documented the suggested approach in e681b40. More on motivation for this change: #21 (comment).
We don’t expect this to be a huge issue, and we’re going to give this a try. We can reconsider this before 16 if the problem turns out widespread. |
Hi,
I have a package that has
react
as apeerDependency
and provides PropTypes for the component it exports. Now that theprop-types
is a separate package I would like to use it as apeerDependency
as well but in an opt-in way (for users that use TypeScript, PropTypes are redundant). Is there a recommended way of handling this situation?Thanks
The text was updated successfully, but these errors were encountered: