New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to render wrapped Panel under Collapse? #73
Comments
Only If you want to extract common logic, try: function somePanelGenerator(props) {
return <Collapse.Panel {...props} />
}
<Collapse>
{somePanelGenerator(props)}
</Collapse> |
@benjycui Thanks for you answer. |
This would be a great addition to the docs. |
I spent some time on that issue... cause special function is anti-pattern for me and It's doable 🎉 , you just need to pass rest props to ie. Collapse.Panel (check source code of rc-panel to understand it)
and then use it like that:
|
If you're using typescript both hoc and Panel types are not typed correctly so you'll need to pass at least isActive, openProps and key props |
Just to expand a little on this for the Typescript users out there: If you want to wrap inner components like
You can see what's happening under the hood here: The You can also override whichever props you want like
|
We have a prop name "forceRender" that we can pass inside the Panel component of Collapse, it will help to render content inside Panel without clicking on the header.
|
Since
List.jsx
andMyPanel.jsx
contains complex business, spilt Collapse and Panel into two files.But it doesn't work.So how to render wrapped Panel under Collapse?
The text was updated successfully, but these errors were encountered: