N
N
n1ksON2020-11-26 13:17:06
React
n1ksON, 2020-11-26 13:17:06

How to destructure props in React?

Props come from store.js. But it is not possible to destructure (or destructure) them.
Here is what is stored in props:

state = { 
    inner: {
        param1: 'text',
        param2: 123
    }
}

This is how I tried to get it:
const App = ({ param1, param2 }) => { //  props.state.inner.param1
// undefined
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan V, 2020-11-26
@n1ksON

const App = ({ inner: { param1, param2 }}) => {  
...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question