Deconstruct props doesn't remove children
See original GitHub issueHi,
I found a bug when you deconstruct props, children are not deleted properly.
Here an example: https://codesandbox.io/s/k13proo6ko
in my case it generates a RangeError: Maximum call stack size exceeded.
const MyDiv = ({ children, ...rest }) => {
console.log(rest);
return (
<div {...rest}>
<div {...rest}>{children}</div>
</div>
);
};
Here the rest object still contains the children field. Maybe _objectWithoutPropertiesLoose is not interpreted correctly.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How i can destructuring {this.props.children}? - Stack Overflow
Try though first removing propTypes temporarily to see if the linting error via this destructuring assignment is resolved. If you continue to ...
Read more >Destructuring of Props in ReactJS - GeeksforGeeks
Destructuring is a characteristic of JavaScript, It is used to take out sections of data from an array or objects, We can assign...
Read more >Take `children` off `props` · Issue #4694 · facebook/react
Having children on props means that the props object saved in the ReactElement can't be hoisted up by an intelligent runtime, which would ......
Read more >Learn the basics of destructuring props in React
The downside to destructuring in class components is that you'll end up destructuring the same props each time you use it in a...
Read more >Using ES6 To Destructure Deeply Nested Objects in ... - ITNEXT
The pattern is starting to make sense when deconstructed object by object. One JS Object Within Three More Objects. So, for an even...
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
No, the property is removed properly.
console.log
is lazy and prints the objects state after preactsh
function modified it. You can observe this behavior by loggingrest.children
which eveluates toundefined
instead ofrest
example.@Kanaye is right. The issue is caused by us mutating
props
directly. Looks like we need to cloneprops
increateElement/h
.@jeremycare nah, that’s still an issue and unexpected behaviour. We should fix that 😃