{...props} causes TypeError
See original GitHub issueThis code crashes due to children
being assigned to the <div>
. I think it works in React. I’m assuming React doesn’t pass children
when it’s empty. Not sure though.
TypeError: Attempted to assign to readonly property.
TypeError: undefined is not an object (evaluating 'e.childNodes')
Broken Code
export default ({...props}) =>
<div {...props}>Example!</div>
Working Code
export default ({children, ...props}) =>
<div {...props}>Example!</div>
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (10 by maintainers)
Top Results From Across the Web
React error : TypeError: props.globalChange is not a function
I am having a problem in props sending in the same component and the function is not function issue coming. So how to...
Read more >Properties of the uninitialized this.props should not be accessed
Accessing properties of the uninitialized this.props causes a TypeError exception because this.props is always undefined in the below cases.
Read more >TypeError Handling in React.js for Map Function | Pluralsight
Learn why this error occurs and how to fix it: Uncaught TypeError: this.props.data.map is not a function.
Read more >Uncaught TypeError: this.props.tracks is undefined - Projects
It's caused by the fact that you're not passing props into the where TrackList is rendered in the Playlist component yet, so there...
Read more >How to Read React Errors (fix 'Cannot read property of ...
Follow the Clues: How to Diagnose the Error · TypeError is the kind of error · Cannot read property means the code was...
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 Free
Top 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
In Inferno & Preact,
children
gets stripped from theprops
object.Another interesting thing when passing children to props was that you can use such thing
instead of the link inside the Foo tag
Kinda like the first one and found it useful.