-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Proposal: Remove React.DOM (dom component factories) API and release as new module #6169
Comments
👍 I discovered |
These also work today: const div = React.createFactory('div');
// then div(...)
const e = React.createElement;
// then e('span', ...) |
Would it make sense to add this as part of ReactDOM rather than adding to package fatigue with another module? |
Potentially but we would have to change the API so there would be code changes required anyway ( |
👍 |
Which |
@matystl I really don't think we'll change any APIs or behaviors. The idea is not to make these methods more flexible and support different use cases, simply to move them from their current location. People are welcome to use hyperscript or similar if they want other APIs instead. |
is there somethng to PR here? would you just add another build step to produce the package from the main repo, or a new repo just for the factories (perhaps in the reactjs org)? In any case I'd be happy to PR something, just not sure what the best way to do it might be |
I would probably move it to a separate project in the org, but nothing for anybody to do at the moment. |
In future this could be implemented as easily as: import { createFactory } from 'react'; // 'react-dom'? 'react/dom'?
export default new Proxy(Object.create(null), {
get(target, type) {
return createFactory(type);
}
}); |
@chicoxyzzy Not if you care about browser support or GCC advanced optimization. |
Does this already do it? |
Yes however that depends on the |
that's why I said "in future" :)
this might be an issue but I think it could be solved |
Is there any reason to have these functions at all, vs JSX compiling to plain objects? It could be more user-friendly for the hand-written cases as well, and no need to |
I don’t have full context on this so I can’t give a good reply. Here’s what I know about this:
|
Will fiber reconciler help to solve owner concept issue anyhow? The whole issue looks too complicated. Do you mind to split it into different tasks? |
This issue is just about extracting React.DOM element factories into a separate module because they are niche and require maintaining a whitelist. There is a separate issue about removing ReactCurrentOwner: #6350. Feel free to discuss it there! |
Yes I understand that. Actually this is a task I'd be glad to help with. But it's not clear if there is a consensus on how to solve a problem. That's why I propose to split it into separate subtask. |
To split what into a separate subtask? As far as I can see this is the only issue concerning this thread. |
I made a module with all the factories in 15.1.0 React.DOM |
@moodysalem |
No, it wouldn't make a difference. |
@chicoxyzzy Points 2 and 3 are observations, there’s nothing actionable there as far as I can see. Point 1 is a problem described in #6350. |
I think we will be able to close this when we release 15.6. 🎈 |
We did. |
The
React.DOM
API (not to be confused withReactDOM
) does not make sense in the greater scheme of the React API being used in other rendering environments like React Native or GL or <insert anything that isn't the DOM>. TheReact.*
API is meant to be universal in that sense. We are never going to add React.iOS.However, these factories don't actually have any implementation details that rely on actual DOM details, they essentially just map like so:
React.DOM.div = (...args) => React.createElement('div', ...args)
, which is why they ended up in the universal React package and not in ReactDOM.This would only impact people who don't currently use JSX and have held out using the function call syntax.
<div/>
now (and has for over a year) transforms toReact.createElement('div')
. The conveniences of the function syntax are a big deal for many people (especially coffeescript users and those who are strongly anti-JSX) so we don't want to break anybody, but we would like to migrate them from the core React API.So the proposal would be a new package which just exports the exact set of things that
React.DOM
currently makes available. It would require some small changes to your code and a new package dependency, but is otherwise identical. Here's what the change might look like.The text was updated successfully, but these errors were encountered: