In the case below, where I need to update the state if some mode was enabled, is there any performance implication of unconditionally copying props.isScaffoldingMode to the state?
I wonder, if I should use didUpdate for this case or copy the prop only when it changes.
I am unsure if getDerivedStateFromProps causes a full re-render, like setting the state in didUpdate would in this case.
Thank you for your time.
static getDerivedStateFromProps(nextProps, prevState) {
let newState = { prevIsScaffoldingMode: nextProps.isScaffoldingMode };
if (nextProps.isScaffoldingMode && !prevState.prevIsScaffoldingMode) {
const scaffoldingState = StandardItemComponent.prepareScaffoldingMode(nextProps);
newState = { ...newState, ...scaffoldingState };
}
return newState;
}