A
A
Andrew2017-07-15 01:17:55
React
Andrew, 2017-07-15 01:17:55

Why are props immutable?

I'm more interested in this question from the point of view of how it works that they cannot be changed, if you console props, you can see a regular object, how are they made immutable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Gushchin, 2017-07-15
@iNikNik

There is a special method :

const freezedObject = Object.freeze({ a: 1, b: 5 })

freezedObject.a = 'quux'; // тихо ничего не делает

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question