Giter Site home page Giter Site logo

Allow async tree walkers? about react-vtree HOT 3 OPEN

lodin avatar lodin commented on May 20, 2024
Allow async tree walkers?

from react-vtree.

Comments (3)

strogonoff avatar strogonoff commented on May 20, 2024

On second thought, I think it should be possible within react-vtree as is: e.g. I could start fetching data when node is expanded, then once it’s finished update my structure with newly received child node data and run recomputeTree() with refresh. Going to see if that would allow for good UX.

from react-vtree.

Lodin avatar Lodin commented on May 20, 2024

Hi @strogonoff, sorry for long delay.

According to the react-vtree idea, all the data changes should be done outside of the tree component. After the data fetching is over, you have to update the treeWalker function (if you use hooks, it is possible with useCallback with your data variable as deps), and the tree traversing will be done again building the tree with the new data. To start the data fetching simply add the fetching function to the each node withing the treeWalker and call it in the Node component.

I'm going to prepare an example for it, so it may be more descriptive. I'll publish it here as well.

from react-vtree.

strogonoff avatar strogonoff commented on May 20, 2024

Understood. That’s the idea I arrived at in the end: when node is expanded, start data query somewhere else and pass isLoading to node component in meantime, then once data is fetched remove isLoading, update tree structure with new data, and recomputeTree.

If I finish this component I’m building with react-vtree soon enough, I’ll try to contribute an example as well…

from react-vtree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.