remove the need for `props.attributes`
See original GitHub issueThis is one of the most awkward things when defining custom Node components. Right now you have to remember to mix in <Component {...props.attributes} />
to your components, because some things depend on it…
findDOMNode
depends on anattributes.data-key
property being set.- Right-to-left text direction depends on an
attributes.dir
property being set.
But why not solve this with React’s refs
instead? In the core <Node>
component, when the ref is established it could just use ReactDOM.findDOMNode
itself and set those two properties on the node’s element?
This prevents the user from specifying exactly which element to mix the attributes in on, but I’m not sure that’s even a thing we want to allow…
Feels like this would be a super simple, but nice API improvement. If anyone sees holes in the plan please point them out!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to avoid VueJS to remove the props attributes in the DOM?
I have a prop on a component that is correctly passed to the component. The value is correctly set inside the component. But...
Read more >Remove props... - Github-Gist
The first snippet won't work: React.cloneElement(someComponent, props) merges props, so foo and bar will still be there.
Read more >Removing Object Properties with Destructuring
In this post you'll learn how to remove properties from an object in JavaScript using ... We can't reference [removeProp] so we'll need...
Read more >Unknown Prop Warning - React
The unknown-prop warning will fire if you attempt to render a DOM element with a prop that is not recognized by React as...
Read more >.removeProp() | jQuery API Documentation
It's almost always better to use .prop() to set native properties to false instead of removing them. Additional Notes: In Internet Explorer prior...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ianstormtaylor It would be beautiful to remove
props.attributes
, but we should avoid overusingReactDOM.findDOMNode
.findDOMNode
is considered an anti-pattern and could be removed in a future React release. See this discussion for example.Downshift takes a similar approach to mixing in library controlled props with prop getters. Also check out the blog post with more details.