This lib is amazing, thanks for sharing this project with the community!
About my request, it would be great to include examples in the docs/website about using High Order Components while creating custom components, please check my below example and let me know what you think! <3
src/hocs/withPixiDraggable.tsx
import { _ReactPixi } from '@pixi/react';
import { useRef, type ComponentType, useState } from 'react';
import { FederatedPointerEvent } from 'pixi.js';
Description
Hello folks, hope you're doing!
This lib is amazing, thanks for sharing this project with the community!
About my request, it would be great to include examples in the docs/website about using High Order Components while creating custom components, please check my below example and let me know what you think! <3
let index = 1; export function withPixiDraggable(
WrappedComponent: ComponentType
): ComponentType {
return function (props) {
const containerRef = useRef();
const isDragging = useRef(false);
const offset = useRef({ x: 0, y: 0 });
const [position, setPosition] = useState({
x: props.x || (props.position ? props.position[0] : 0) || 0,
y: props.y || (props.position ? props.position[1] : 0) || 0,
});
const [alpha, setAlpha] = useState(1);
const [zIndex, setZIndex] = useState(index);
}; }
Wondering if you can include HOCs like this from this project, any feedback is really appreciated! <3