Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 846 Bytes

File metadata and controls

34 lines (26 loc) · 846 Bytes
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
nested destructuring
reactpatterns
react patterns
reactjspatterns
reactjs patterns
react
reactjs
react techniques
react tips and tricks
version Nested destructuring
image /img/reactpatterns-cover.png

Destructuring also applies to objects nested in objects.

For example

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

  // ...
}