We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const [path, setPath] = useState<SkPath>(Skia.Path.Make()); const panGesture = useMemo( () => Gesture.Pan() .onBegin(e => { 'worklet'; const coords = getRelativeCoords(viewRef as any, e.absoluteX, e.absoluteY); path.moveTo(coords?.x||0, coords?.y||0) }) .onUpdate(e => { 'worklet'; const coords = getRelativeCoords(viewRef as any, e.absoluteX, e.absoluteY); path.lineTo(coords?.x||0, coords?.y||0); }) [], ); return ( <GestureDetector gesture={panGesture}> <View ref={viewRef} style={styles.canvas}> <Canvas style={{flex: 1}}> {/* Drawing path */} <Path path={path} // style="stroke" color={strokeColor} stroke={{width: typeof strokeWidth === 'number' ? strokeWidth : strokeWidth.value}} /> </Canvas> </View> </GestureDetector> );
it doesn't work. how can I change Path without rerendering?
1.3.11
Above code
no
The text was updated successfully, but these errors were encountered:
@doublelam Use sharedValue if you don't want to rerender entire screen:
const currentPath = useSharedValue(Skia.Path.Make()); const panGesture = useMemo( () => Gesture.Pan() .onBegin(e => { 'worklet'; currentPath.modify((v) => { const coords = getRelativeCoords(viewRef as any, e.absoluteX, e.absoluteY); v.lineTo(coords.x || 0, coords.y || 0); return v; }); }) .onUpdate(e => { 'worklet'; const coords = getRelativeCoords(viewRef as any, e.absoluteX, e.absoluteY); currentPath.modify((v) => { const coords = getRelativeCoords(viewRef as any, e.absoluteX, e.absoluteY); v.lineTo(coords.x || 0, coords.y || 0); return v; }); }) [], ); ..... // next code stays same
Sorry, something went wrong.
@wcandillon issue can be closed
Ok now it works, but I need to use derived value or it does not work
const derived = useDerivedValue(() => { return pathSharedVal.value.toSVGString() });
Thank you!
No branches or pull requests
Description
it doesn't work. how can I change Path without rerendering?
Version
1.3.11
Steps to reproduce
Above code
Snack, code example, screenshot, or link to a repository
no
The text was updated successfully, but these errors were encountered: