React.Component versus React.PureComponent

Hi Campers,

I have been reading about when React.Component and React.PureComponent are used and i came across This stackoverflow question. According to the most up-voted answer, one requirement for correct usage of PureComponent is: State/Props should be an immutable object. What exactly is an immutable object? I know primitive data types like string, integer, boolean e.t.c are immutable but how can an object be immutable?

An object can be immutable by practice or design.

For example, objects in redux are usually immutable by practice - there typically is nothing preventing you from mutating the objects, but you just don’t.

You can also make objects immutable by design. For example, you could use Object.freeze. There are also libraries like immutable.js.

Personally, I think PureComponent is overblown. I find that most of the time, a well used shouldComponentUpdate is leaner.