Skip to content

Refactor Components to use Hooks #1320

@Xiot

Description

@Xiot

There is a desire to refactor the basic building blocks of react-vis into hooks.
This should clean up the code, and make sharing functionality, which is currently done via inheritance, much easier.

I think we need a guiding approach on how we want to implement this.
The main point that we will need a plan for is how to share data down the tree.
As of now, the Plot injects props into its children, which works, however it makes typing and discovery of what is passed a little trickier.

If we move the prop passing to a single shared context, then we can easily share the data, however, any change to the context value, will cause a re-render for any component (whether it needs the new data or not) that accesses it through the hook.

Re-rendering of child components was already a little bit of a problem as the props that were injected weren't properly memoized (see #1314)

The ideal approach would be one that only causes re-rendering to the components that actually require it.

I'm starting this thread so that we can start talking about approaches, since it seems that a lot of people are interested in helping with the migration to hooks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions