Skip to content

Feature Request: Make library declarative #22

@jeremygottfried

Description

@jeremygottfried

Hi, thank you so much for putting the effort into building this! I think this would be super useful if it was a little more declarative in line with other modern libraries like react-dnd and react-spring. Calling sendReparentableChild manually is a side effect and makes it much harder to use the library.

My suggestion is to have something like this:

const Example = ({ showParentA, }) => {
  const { child } = useReparentable({
    child: <Child/>
  })

  return (
    showParentA
    ? <ParentA>
        {child}
      </ParentA>
    : <ParentB>
        {child}
      </ParentB>
  )
}

In the example above, child would be stored in memory so it can be passed around to components that render conditionally. Having a hook that handles "sending" to different parents would make this library much more intuitive. I could see it being something as simple as that hook calling sendReparentableChild under the hood, with slightly more functionality to make it work for conditional rendering.

Just food for thought!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions