diff --git a/packages/taro-swan/src/index.js b/packages/taro-swan/src/index.js index a058654d175d..9122050c03b8 100644 --- a/packages/taro-swan/src/index.js +++ b/packages/taro-swan/src/index.js @@ -33,7 +33,8 @@ import { useImperativeHandle, useContext, createContext, - memo + memo, + setIsUsingDiff } from '@tarojs/taro' import { shallowEqual } from '@tarojs/utils' @@ -87,7 +88,8 @@ export const Taro = { useContext, createContext, memo, - shallowEqual + shallowEqual, + setIsUsingDiff } export default Taro diff --git a/packages/taro-swan/src/lifecycle.js b/packages/taro-swan/src/lifecycle.js index 176d43bc0cf4..72993e33d509 100644 --- a/packages/taro-swan/src/lifecycle.js +++ b/packages/taro-swan/src/lifecycle.js @@ -3,7 +3,8 @@ import { internal_safe_set as safeSet, commitAttachRef, Current, - invokeEffects + invokeEffects, + getIsUsingDiff } from '@tarojs/taro' import { componentTrigger } from './create-component' import { shakeFnFromObject, isEmptyObject, diffObjToPath, isFunction, isUndefined, isArray } from './util' @@ -173,7 +174,7 @@ function doUpdate (component, prevProps, prevState) { } data['$taroCompReady'] = true - const dataDiff = diffObjToPath(data, component.$scope.data) + const dataDiff = getIsUsingDiff() ? diffObjToPath(data, component.$scope.data) : data const __mounted = component.__mounted let snapshot if (__mounted) {