Tools API ⚙️
<Reparentable />#
A custom component to enable reparenting.
props#
| Name | Type | Description |
|---|---|---|
| id | string | The id of the component it must be unique must be unique among all Reparentables. Required |
| children | ReactNode | The children that can be transferred. |
| findFiber | func | A 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#
| Name | Type | Description |
|---|---|---|
| fromParentId | string | The id of the current Reparentable parent. Required |
| toParentId | string | The id of the new Reparentable parent. Required |
| child | string / number | The key or the index of the child to be transferred. Required |
| position | string / number | The 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 . |
| skipUpdate | boolean | If true, the send method will not transfer the DOM nodes. Default false . |
returns#
| Type | Description |
|---|---|
| number | The 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#
| Name | Type | Description |
|---|---|---|
| toParent | ParentFiber | The ParentFiber linked with the new parent component. Required |
| child | string / number | The key or the index of the child to be transferred. Required |
| position | string / number | The 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 . |
| skipUpdate | boolean | If true, the send method will not transfer the DOM nodes. Default false . |
returns#
| Type | Description |
|---|---|
| number | The 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#
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The children that can be transferred. |
| parentRef | React.Ref<ParentFiber> | The ref of the ParentFiber instance. Required |
| findFiber | func | A function to change the parent fiber. Signature (parent: fiber) => fiber |
createParent( instance, [findFiber] ): parent#
A method to generate a ParentFiber instance.
arguments#
| Name | Type | Description |
|---|---|---|
| instance | React.Component | A class component instance, must be called before the component is mounted. Required |
| findFiber | func | A function to change the parent fiber. Signature (parent: fiber) => fiber |
returns#
| Type | Description |
|---|---|
| ParentFiber | The parentFiber instance. |
useParent( ref, [findFiber] ): parent#
An hook to generate a ParentFiber instance.
arguments#
| Name | Type | Description |
|---|---|---|
| ref | React.RefObject | The ref of the parent element. Required |
| findFiber | func | A function to change the parent fiber. Signature (parent: fiber) => fiber |
returns#
| Type | Description |
|---|---|
| ParentFiber | The ParentFiber instance. |