Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function observerSCU(nextProps, nextState) {
if (isUsingStaticRendering()) {
console.warn(
"[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."
)
}
// update on any state changes (as is the default)
if (this.state !== nextState) {
return true
}
// update if props are shallowly not equal, inspired by PureRenderMixin
// we could return just 'false' here, and avoid the `skipRender` checks etc
// however, it is nicer if lifecycle events are triggered like usually,
// so we return true here if props are shallowly modified.
return !shallowEqual(this.props, nextProps)
}
function makeComponentReactive(render) {
if (isUsingStaticRendering() === true) return render.call(this)
/**
* If props are shallowly modified, react will render anyway,
* so atom.reportChanged() should not result in yet another re-render
*/
setHiddenProp(this, skipRenderKey, false)
/**
* forceUpdate will re-assign this.props. We don't want that to cause a loop,
* so detect these changes
*/
setHiddenProp(this, isForcingUpdateKey, false)
// Generate friendly name for debugging
const initialName =
this.displayName ||
this.name ||
patch(target, "componentWillUnmount", function() {
if (isUsingStaticRendering() === true) return
this.render[mobxAdminProperty] && this.render[mobxAdminProperty].dispose()
this[mobxIsUnmounted] = true
})
return componentClass