Skip to content

Commit

Permalink
fix(taro-weapp): 调用 forceUpdate 时应该不去触发 shouldComponentUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Oct 22, 2018
1 parent a187d8e commit 2bf0838
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/taro-weapp/src/component.js
Expand Up @@ -21,6 +21,7 @@ class BaseComponent {
nextProps = {}
_dirty = true
_disable = true
_isforceUpdate = false
_pendingStates = []
_pendingCallbacks = []
$router = {
Expand Down Expand Up @@ -71,6 +72,7 @@ class BaseComponent {
if (isFunction(callback)) {
(this._pendingCallbacks = this._pendingCallbacks || []).push(callback)
}
this._isforceUpdate = true
updateComponent(this)
}

Expand Down
2 changes: 2 additions & 0 deletions packages/taro-weapp/src/lifecycle.js
Expand Up @@ -35,6 +35,7 @@ export function updateComponent (component) {
let skip = false
if (component.__mounted) {
if (typeof component.shouldComponentUpdate === 'function' &&
!component._isForceUpdate &&
component.shouldComponentUpdate(props, state) === false) {
skip = true
} else if (typeof component.componentWillUpdate === 'function') {
Expand All @@ -44,6 +45,7 @@ export function updateComponent (component) {
component.props = props
component.state = state
component._dirty = false
component._isForceUpdate = false
if (!component.__componentWillMountTriggered) {
component.__componentWillMountTriggered = true
componentTrigger(component, 'componentWillMount')
Expand Down

0 comments on commit 2bf0838

Please sign in to comment.