Tools API ⚙️
#
<Reparentable />A custom component to enable reparenting.
#
propsName | 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] ): indexRemove a child from a Reparentable component and add it to a new Reparentable component. DOM nodes will also be sent (optional).
#
argumentsName | 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 . |
#
returnsType | 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] ): indexRemove a child from this instance and add it to the provided ParentFiber instance.
#
argumentsName | 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 . |
#
returnsType | 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.
#
PropsName | 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] ): parentA method to generate a ParentFiber instance.
#
argumentsName | 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 |
#
returnsType | Description |
---|---|
ParentFiber | The parentFiber instance. |
#
useParent( ref, [findFiber] ): parentAn hook to generate a ParentFiber instance.
#
argumentsName | 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 |
#
returnsType | Description |
---|---|
ParentFiber | The ParentFiber instance. |