File tree Expand file tree Collapse file tree
packages/react-vant/src/components/collapse Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,10 +28,11 @@ const [bem] = createNamespace('collapse')
2828
2929const Collapse : React . FC < CollapseProps > = props => {
3030 const { accordion } = props
31- const initExpandedDefault = accordion ? '' : [ ]
32- const { initExpanded = initExpandedDefault } = props
31+ const { initExpanded = accordion ? '' : [ ] } = props
3332 const innerEffect = useRef ( false )
34- const [ expanded , setExpanded ] = useState ( ( ) => props . value ?? initExpanded )
33+ const [ expanded , setExpanded ] = useState <
34+ string | number | Array < number | string >
35+ > ( ( ) => props . value ?? initExpanded )
3536 const updateName = ( name : number | string | Array < number | string > ) => {
3637 innerEffect . current = true
3738 setExpanded ( name )
@@ -69,6 +70,7 @@ const Collapse: React.FC<CollapseProps> = props => {
6970 innerEffect . current = false
7071 return
7172 }
73+ if ( props . value === undefined ) return
7274 setExpanded ( props . value )
7375 } , [ props . value ] )
7476
You can’t perform that action at this time.
0 commit comments