I understand that React tutorials and documentation warn in no uncertain terms that state should not be directly mutated and that everything should go through setState
My current understanding is based on this and this answer:
IF you don't use shouldComponentUpdate
or any other lifecycle methods (like componentWillReceiveProps
, componentWillUpdate
, and componentDidUpdate
) where you compare the old and new props/state
THEN
its fine to mutate state
and then call setState()
, otherwise it is not fine.