How to transfer data from an object to separate variables, so that when using each time you do not write object.name, object.text, etc.?

const { object } = this.props; 

that doesn't work. undefined

  conxt {text} = object.text 

    2 answers 2

    This is called object restructuring.

     const object = { name: 'name1', text: 'text1' } const { name, text } = object; console.log(name, text) 

    • Thank! it turned out - werty

    If you have props undefined, then object will also be undefined. Check what this is tied to.

    • I have not undefined. when I just output object.text, then everything is ok. as soon as I bring change and write it there and bring it out, undefined - werty
    • if I just output object.text, then undefined first, and then the value itself is output. why so - werty
    • when I write to a variable and output it, just undefined - werty