question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose setActiveKey for Collapse

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

I have a series of nested Collapse elements which takes 3 seconds to render. I want to programmatically set the activeKey. If i use state props, there is a long delay while the whole nested series re-renders. I tried to save a ref to the Collapse element, but it does not help because, there is no function to set the active key (even though setActiveKey is present in the Collapse class in modules).

This should be a very simple addition to the API surface as the underlying function is already there (and used on user click).

What does the proposed API look like?

CollapseRef.setActiveKey([stringKey]);

Collapse already has and uses the method internally, I just want it exposed on the CollapseRef.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
yesmeckcommented, Apr 12, 2019

I don’t think we will expose a API like this, it’s an anti-pattern in React.

0reactions
gotjoshuacommented, Apr 13, 2019

@afc163, I know you are super busy, but I’d like you to understand the use case a bit better. Even if you stay with your decision…

If I control activeKey via state and props, then collapsing a single top level element, takes over 3 seconds to render. If I am not controlling activeKey, clicking to collapse an element is instant (no re-render).

I now did a terribly ugly workaround:

document.querySelector(`#${collapseElementID} > .ant-collapse-header`).click();

I would much prefer to use:

collapseReactRef.setActiveKey( correctPanelKey || [] );

For me, it would be great if you could simply acknowledge that 3 seconds to open or close a collapse element is far too long. If you have a less ugly workaround - or way to use state+props without rerendering, even better… If you could reconsider exposing setActiveKey, that would be amazing.

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically Open and Close antd / react Collapse Component
The Collapse react component has setActiveKey (and uses it on user click) but it is not exposed to the Collapse Node reference. Is...
Read more >
Collapse - Bootstrap
Click the buttons below to show and hide another element via class changes: .collapse hides content .collapsing is applied during transitions .collapse.show ...
Read more >
Introduction — Blender Manual
As such, they typically have no attributes, and are controlled by settings exposed in separate sections of the Properties.
Read more >
TODO.txt - external/github.com/ocornut/imgui - Git at Google
window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? - window: expose contents size.
Read more >
imgui/TODO.txt at 4649967112f71b149cc4c8e67c28d815d5edf0e9 ...
window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? - window: expose contents size.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found