-
Notifications
You must be signed in to change notification settings - Fork 50.5k
Description
One of the things holding us back right now is that we don't have a stable public API. I'd really like to cut Instagram over to the npm version of React but unfortunately it doesn't include some of the addons that we need because of this issue. I'd like to propose the following changes:
Consistent, iterable this.props.children
this.props.children gets wrapped in a new ReactChildIterator object -- basically a thin wrapper around ReactChildren.map(). This means that people can actually introspect this.props.children without assuming it's an array or a nested object or something.
I don't think memory utilization is a big problem today so I think this change would be OK, especially if it is implemented lazily. I know that @dnolen wants something like this too if he can plug in his own lazy child data structure.
I do think it's important we solve this. Another option I was thinking of was putting mapChildren() on ReactCompositeComponent -- but that begs the question of adding onlyChild() as well and I think the API would become confusing.
cloneWithProps() on ReactComponent
I think this function is very helpful and hard to use externally right now. Adding it to the public API of ReactComponent makes sense to me. Does anyone think that there is potential for overuse here?
Public injection APIs
I think we should centralize all injection points for React in a ReactInjection module and make it public as React.injection. There's no reason why you should need to check out the repo to configure a custom React.
Rename lib/ to internal/ in the react npm module
For many addons we'll need to do stuff like require('react/lib/ReactUpdates') for the foreseeable future. Let's just embrace it for now and rename lib/ to internal_do_not_use_or_you_will_be_fired/ so non-core projects don't depend on this.
Put each add-on into its own npm module
Everything in https://github.com/facebook/react/pull/745/files
Add new react-svg npm package
This will export the DOMPropertyConfig which can be injected with the new public ReactInjection APIs.
Use wzrd.in for package builds
We can put our own cache in front of it so we are good citizens. This way people can build their own react-whatever.min.js without us having to provide a million builds or a config tool.