| id | nested-destructuring | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| sidebar_label | Nested destructuring | |||||||||
| title | Nested Destructuring | |||||||||
| description | Nested destructuring | React Patterns, techniques, tips and tricks in development for React developers. | |||||||||
| keywords |
|
|||||||||
| version | Nested destructuring | |||||||||
| image | /img/reactpatterns-cover.png |
Destructuring also applies to objects nested in objects.
Without destructuring:
function setIndexFromRoute(props) {
const modalList = props.modalList
const pathname = props.location.pathname
// ...
}Destructuring the nested props object.
function setIndexFromRoute(props) {
const { modalList, location: { pathname } } = props
// ...
}