Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.componentWillReact && this.componentWillReact()
this.forceUpdate()
})
}
let result
let exception
this._reaction.track(() => {
try {
result = originRender.call(this, null, null, args[2])
} catch (e) {
exception = e
}
})
if (exception) {
errorsReporter.emit(exception)
throw exception
}
return result
}
target._createData = function (...args) {
let result
let exception
if (this._reaction instanceof Reaction) {
this._reaction.track(() => {
try {
result = originRender.call(this, null, null, args[2])
} catch (e) {
exception = e
}
})
} else {
result = originRender.call(this, null, null, args[2])
}
if (exception) {
errorsReporter.emit(exception)
throw exception
}
return result
}
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()
render () {
const originProps = mapStoreToProps(grabStoresFn, this.props)
return createElement(sourceComponent, {
...originProps,
ref: ref => {
originProps.ref && originProps.ref(ref)
if (ref) {
this.__observeInstance = ref
}
}
})
}
render () {
const originProps = mapStoreToProps(grabStoresFn, this.props)
return createElement(sourceComponent, {
...originProps,
ref: ref => {
originProps.ref && originProps.ref(ref)
if (ref) {
this.__observeInstance = ref
}
}
})
}
constructor (props, isPage) {
super(Object.assign(...arguments, mapStoreToProps(grabStoresFn, props)), isPage)
}
_constructor () {
Object.assign(this.props, mapStoreToProps(grabStoresFn, this.props))
super._constructor && super._constructor(this.props)
}
}
function createStoreInjector (grabStoresFn, injectNames, sourceComponent) {
class Injector extends Component {
static isMobxInjector = true
static config = sourceComponent.config || {}
static displayName = getInjectName(sourceComponent, injectNames)
__observeInstance
render () {
const originProps = mapStoreToProps(grabStoresFn, this.props)
return createElement(sourceComponent, {
...originProps,
ref: ref => {
originProps.ref && originProps.ref(ref)
if (ref) {
this.__observeInstance = ref
}
}
})
}
componentDidShow () {
function createStoreInjector (grabStoresFn, injectNames, sourceComponent) {
class Injector extends Component {
static isMobxInjector = true
static config = sourceComponent.config || {}
static displayName = getInjectName(sourceComponent, injectNames)
__observeInstance
render () {
const originProps = mapStoreToProps(grabStoresFn, this.props)
return createElement(sourceComponent, {
...originProps,
ref: ref => {
originProps.ref && originProps.ref(ref)
if (ref) {
this.__observeInstance = ref
}
}
})
}
componentDidShow () {