Tools API ⚙️

<Reparentable />#

A custom component to enable reparenting.

props#

NameTypeDescription
idstringThe id of the component it must be unique must be unique among all Reparentables.

Required
childrenReactNodeThe children that can be transferred.
findFiberfuncA function to change the parent fiber.

Signature (parent: fiber) => fiber

SendReparentableChild( fromParentId, toParentId, child, position, [skipUpdate] ): index#

Remove a child from a Reparentable component and add it to a new Reparentable component. DOM nodes will also be sent (optional).

arguments#

NameTypeDescription
fromParentIdstringThe id of the current Reparentable parent.

Required
toParentIdstringThe id of the new Reparentable parent.

Required
childstring / numberThe key or the index of the child to be transferred.

Required
positionstring / numberThe index or the key of the child whose position will be used as an index (insert before). The child is added at the bottom if -1 is provided or the index is greater than the number of children. The child is added at the bottom if none of the children have that key

Required .
skipUpdatebooleanIf true, the send method will not transfer the DOM nodes.

Default false .

returns#

TypeDescription
numberThe index in which the child is added. If the child to remove is not found (invalid key), or one of the parents is not found returns -1.

ParentFiber#

parent.sendChild( toParent, child, position, [skipUpdate] ): index#

Remove a child from this instance and add it to the provided ParentFiber instance.

arguments#

NameTypeDescription
toParentParentFiberThe ParentFiber linked with the new parent component.

Required
childstring / numberThe key or the index of the child to be transferred.

Required
positionstring / numberThe index or the key of the child whose position will be used as an index (insert before). The child is added at the bottom if -1 is provided or the index is greater than the number of children. The child is added at the bottom if none of the children have that key

Required .
skipUpdatebooleanIf true, the send method will not transfer the DOM nodes.

Default false .

returns#

TypeDescription
numberThe index in which the child is added, if the child to remove is not found (invalid key) returns -1.

<Parent />#

A component that generate a ParentFiber instance.

Props#

NameTypeDescription
childrenReactNodeThe children that can be transferred.
parentRefReact.Ref<ParentFiber>The ref of the ParentFiber instance.

Required
findFiberfuncA function to change the parent fiber.

Signature (parent: fiber) => fiber

createParent( instance, [findFiber] ): parent#

A method to generate a ParentFiber instance.

arguments#

NameTypeDescription
instanceReact.ComponentA class component instance, must be called before the component is mounted.

Required
findFiberfuncA function to change the parent fiber.

Signature (parent: fiber) => fiber

returns#

TypeDescription
ParentFiberThe parentFiber instance.

useParent( ref, [findFiber] ): parent#

An hook to generate a ParentFiber instance.

arguments#

NameTypeDescription
refReact.RefObjectThe ref of the parent element.

Required
findFiberfuncA function to change the parent fiber.

Signature (parent: fiber) => fiber

returns#

TypeDescription
ParentFiberThe ParentFiber instance.