Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function doUpdate (component, prevProps, prevState) {
const { state, props = {} } = component
let data = state || {}
if (component._createData) {
// 返回null或undefined则保持不变
if (component.__isReady) {
injectContextType(component)
Current.current = component
Current.index = 0
invokeEffects(component, true)
}
data = component._createData(state, props) || data
if (component.__isReady) {
Current.current = null
}
}
data = Object.assign({}, props, data)
if (component.$usedState && component.$usedState.length) {
const _data = {}
component.$usedState.forEach(key => {
let val = safeGet(data, key)
if (typeof val === 'undefined') {
return
}
if (typeof val === 'object') {
function doUpdate (component, prevProps, prevState) {
const { state, props = {} } = component
let data = state || {}
if (component._createData) {
if (component.__isReady) {
injectContextType(component)
Current.current = component
Current.index = 0
invokeEffects(component, true)
}
data = component._createData(state, props) || data
if (component.__isReady) {
Current.current = null
}
}
data = Object.assign({}, props, data)
if (component.$usedState && component.$usedState.length) {
const _data = {}
component.$usedState.forEach(key => {
let val = safeGet(data, key)
if (typeof val === 'undefined') {
return
}
if (typeof val === 'object') {
function doUpdate (component, prevProps, prevState) {
const { state, props = {} } = component
let data = state || {}
if (component._createData) {
if (component.__isReady) {
injectContextType(component)
Current.current = component
Current.index = 0
invokeEffects(component, true)
}
data = component._createData(state, props) || data
if (component.__isReady) {
Current.current = null
}
}
data = Object.assign({}, props, data)
if (component.$usedState && component.$usedState.length) {
const _data = {}
component.$usedState.forEach(key => {
let val = safeGet(data, key)
if (typeof val === 'undefined') {
return
}
if (typeof val === 'object') {
function doUpdate (component, prevProps, prevState) {
const { state, props = {} } = component
let data = state || {}
if (component._createData) {
if (component.__isReady) {
injectContextType(component)
Current.current = component
Current.index = 0
invokeEffects(component, true)
}
data = component._createData(state, props) || data
if (component.__isReady) {
Current.current = null
}
}
data = Object.assign({}, props, data)
if (component.$usedState && component.$usedState.length) {
const _data = {}
component.$usedState.forEach(key => {
let val = safeGet(data, key)
if (typeof val === 'undefined') {
return
}
if (typeof val === 'object') {
let cbs = []
if (component._pendingCallbacks && component._pendingCallbacks.length) {
cbs = component._pendingCallbacks
component._pendingCallbacks = []
}
Object.keys(data).map(item => {
if (!(item in component.$scope)) {
component.$scope.$set(item, data[item])
} else {
component.$scope[item] = data[item]
}
})
if (__mounted) {
invokeEffects(component)
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Current.current = null
}
if (isFunction(component.componentDidUpdate)) {
component.componentDidUpdate(prevProps, prevState, snapshot)
}
}
if (cbs.length) {
let i = cbs.length
while (--i >= 0) {
function doUpdate (component, prevProps, prevState) {
const { state, props = {} } = component
let data = state || {}
if (component._createData) {
if (component.__isReady) {
injectContextType(component)
Current.current = component
Current.index = 0
invokeEffects(component, true)
}
data = component._createData(state, props) || data
if (component.__isReady) {
Current.current = null
}
}
data = Object.assign({}, props, data)
if (component.$usedState && component.$usedState.length) {
const _data = {}
component.$usedState.forEach(key => {
let val = safeGet(data, key)
if (typeof val === 'undefined') {
return
}
if (typeof val === 'object') {
const cb = function () {
if (component.__mounted) {
invokeEffects(component)
if (component['$$refs'] && component['$$refs'].length > 0) {
component['$$refs'].forEach(ref => {
if (ref.type !== 'component') return
const childs = component.$childs || {}
let target = childs[ref.id] || null
const prevRef = ref.target
if (target !== prevRef) {
commitAttachRef(ref, target, component, component.refs)
ref.target = target
}
})
}
if (component['$$hasLoopRef']) {