Skip to content

Commit

Permalink
fix(react): 修复小程序端使用 suspense 报错
Browse files Browse the repository at this point in the history
react reconciler 增加 hideInstance、unhideInstance 方法
  • Loading branch information
Chen-jj committed Aug 19, 2020
1 parent 6aeda35 commit 39ed72a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/taro-react/src/reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const hostConfig: HostConfig<
unknown, // ChildSet
unknown, // TimeoutHandle
unknown // NoTimeout
> = {
> & {
hideInstance (instance: TaroElement): void
unhideInstance (instance: TaroElement, props): void
} = {
createInstance (type) {
return document.createElement(type)
},
Expand Down Expand Up @@ -94,6 +97,19 @@ const hostConfig: HostConfig<
updateProps(dom, oldProps, newProps)
},

hideInstance (instance) {
const style = instance.style
style.setProperty('display', 'none')
},

unhideInstance (instance, props) {
const styleProp = props.style
let display = styleProp?.hasOwnProperty('display') ? styleProp.display : null
display = display == null || typeof display === 'boolean' || display === '' ? '' : ('' + display).trim()
// eslint-disable-next-line dot-notation
instance.style['display'] = display
},

shouldSetTextContent: returnFalse,
shouldDeprioritizeSubtree: returnFalse,
prepareForCommit: noop,
Expand Down

0 comments on commit 39ed72a

Please sign in to comment.