bvaughn / react-resizable-panels

https://react-resizable-panels.vercel.app/
MIT License
3.87k stars 135 forks source link

`onCollapse` doesn't work. #244

Closed hbseo closed 9 months ago

hbseo commented 9 months ago

react-resizable-panels: 1.0.5

This is my code in Panel component onCollapse={(collapsed: boolean) => { console.log(collapsed); }}

Problem

  1. collapsed value is undefined when the panel is collapsed.
  2. ts(2322) type (collapsed: boolean) => void is not assignable to type PanelOnCollapse
billy-syrett commented 9 months ago

onCollapse doesn't send the state. I'm handling it by storing the state outside the component:

onCollapse={() => setIsCollapsed(true)}
onExpand={() => setIsCollapsed(false)}
hbseo commented 9 months ago

It works thanks. I referred to packages/react-resizable-panels/README.md but I don't think it's updated. I think react-resizable-panels-website is updated. I'll refer to this.