Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function observer (component) {
if (isUsingStaticRendering()) {
return component
}
if (component.isMobxInjector === true) {
console.warn(
"Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"
)
}
const target = component.prototype
const originComponentWillUnmount = target.componentWillUnmount
target.componentWillUnmount = function () {
if (this._reaction) {
this._reaction.dispose()
}
export function observer (component) {
if (isUsingStaticRendering()) {
return component
}
if (component.isMobxInjector === true) {
console.warn(
"Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"
)
}
const target = component.prototype
const originConstructor = target._constructor
target._constructor = function () {
if (this.$scope) {
const initialName = this.displayName || this.name
this._reaction = new Reaction(`${initialName}_${Date.now()}`, () => {
this.componentWillReact && this.componentWillReact()