question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

remove the need for `props.attributes`

See original GitHub issue

This 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 an attributes.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:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AlbertHilbcommented, Oct 27, 2017

@ianstormtaylor It would be beautiful to remove props.attributes, but we should avoid overusing ReactDOM.findDOMNode. findDOMNode is considered an anti-pattern and could be removed in a future React release. See this discussion for example.

1reaction
twobitcommented, Oct 25, 2017

Downshift takes a similar approach to mixing in library controlled props with prop getters. Also check out the blog post with more details.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found