You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @Lodin, can we add a initialScrollToItem prop (which takes an id) in addition to scrollToItem method. The context is, I'm using this react-vtree in a popover component, which shows a list of items, and when the user clicks on it, the id of that node is remembered. So when we again open a tree I want to bring that node into the visible area.
The text was updated successfully, but these errors were encountered:
Hi @bharatpatil. Sorry for making you wait for so long time.
Can we add a initialScrollToItem prop (which takes an id) in addition to scrollToItem method
Why cannot you use the useEffect (or componentDidMount) for doing it manually? The library is designed to be as small as possible, and everything that is not essential for the core functionality shouldn't be included.
useEffect(
() => {
if (scrollToNodeId !== null) {
ref.current?.scrollToItem(scrollToNodeId);
}
},
// Note: only want this to run once
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
I have a more complicated use case where the node id is not known and must be searched for, but unless other need it I'm not going to take the time right now to include it here
Hi @Lodin, can we add a
initialScrollToItem
prop (which takes an id) in addition toscrollToItem
method. The context is, I'm using thisreact-vtree
in a popover component, which shows a list of items, and when the user clicks on it, theid
of that node is remembered. So when we again open a tree I want to bring that node into the visible area.The text was updated successfully, but these errors were encountered: