github Tencent/omi v6.17.3
forceUpdate and UpdateProps

latest releases: v7.7.0, v7.6.18, v7.6.6...
4 years ago

Before v6.17.3

Ignore attributes in html mode and update:

this.update(true)

For example, click on the mask of the pop-up layer to close the pop-up, pass it to the parent component in the react, let the parent component update, while Omi advocates self-update, so that the diff area is smaller.

onMaskClick = ()=> {
  //change props
  this.props.show = false
  //prevent parent component from updating diff without results
  this.prevProps.show = false
  //update self and ignore attributes in html mode
  this.update(true)
  //trigger events, which can be used to change external state variables to maintain consistency, but external components need not be updated
  this.fire('close')
}

Now

Ignore attributes in html mode and update:

this.forceUpdate()

For example, click on the mask of the pop-up layer to close the pop-up, pass it to the parent component in the react, let the parent component update, while Omi advocates self-update, so that the diff area is smaller.

onMaskClick = ()=> {
  this.updateProps({
    show: false
  })
  
  this.fire('close')
}

Don't miss a new omi release

NewReleases is sending notifications on new releases.