Skip to content

Commit

Permalink
fix: collapse 异步bug (#130)
Browse files Browse the repository at this point in the history
* fix: 修复collapse 异步使用bug
  • Loading branch information
Chitanda60 authored Dec 20, 2021
1 parent a4c02fd commit 31f0bc7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/react-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.4.3",
"private": true,
"dependencies": {
"@antmjs/vantui": "1.4.3",
"@antmjs/vantui": "^1.4.3",
"@babel/core": "7.12.3",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
"@svgr/webpack": "5.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/vantui-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},
"dependencies": {
"@antmjs/mini-fix": "^1.12.0",
"@antmjs/vantui": "1.4.3",
"@antmjs/vantui": "^1.4.3",
"@babel/runtime-corejs3": "^7.14.7",
"@tarojs/components": "3.3.11",
"@tarojs/react": "3.3.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/vantui/src/collapse-item/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function setContentAnimate(
.then((rect: any) => {
return process.env.TARO_ENV === 'h5'
? ref.current.clientHeight
: rect.height
: rect?.height
})
.then((height) => {
useAnimation(expanded, mounted, height, setState)
Expand Down
6 changes: 4 additions & 2 deletions packages/vantui/src/collapse-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ export function CollapseItem(
}
})
useEffect(() => {
if (process.env.TARO_ENV === 'h5') {
// if (process.env.TARO_ENV === 'h5') {
setTimeout(() => {
setState((state) => {
return {
...state,
ready: true,
}
})
}
}, 0)
// }
}, [])

const refDom = useRef(null)
Expand Down

0 comments on commit 31f0bc7

Please sign in to comment.