Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return false;
}
// Fixture state for this instance is populated on mount, so a transition
// to an empty state means that this instance is expected to reset
if (!next) {
return true;
}
// If the fixture state for this instance has just been populated, we need
// to compare its values against the default values, otherwise an additional
// render cycle will be always run on init
const prevKey = prev ? prev.renderKey : DEFAULT_RENDER_KEY;
const prevValues = prev
? prev.values
: extractValuesFromObject(children.props);
if (next.renderKey !== prevKey) {
return true;
}
// Because serialized fixture state changes are received remotely, a change
// in one fixtureState.props instance will change the identity of all
// fixtureState.props instances. So the only way to avoid useless re-renders
// is to check if any value from the fixture state props changed.
return !areValuesEqual(next.values, prevValues);
}
setFixtureState(fixtureState => {
const instanceId = getInstanceId(this);
const componentName = getComponentName(getRefType(childRef));
const stateInstance = {
instanceId,
componentName,
values: extractValuesFromObject(componentState)
};
return {
state: replaceOrAddItem(
getFixtureStateState(fixtureState),
state => state.instanceId === instanceId,
stateInstance
)
};
}, this.scheduleStateCheck);
}
setFixtureState(fixtureState => {
const instanceProps = {
instanceId,
componentName,
renderKey: DEFAULT_RENDER_KEY,
values: extractValuesFromObject(children.props)
};
return {
props: replaceOrAddItem(
getFixtureStateProps(fixtureState),
props => props.instanceId === instanceId,
instanceProps
)
};
});
}