How to make further calculations with computed values? #1037
Unanswered
kbrandwijk
asked this question in
Q&A
Replies: 1 comment 2 replies
-
it should be the following: // This value is manipulated with a `useSharedValueEffect` when user pinches to zoom from .75 to 2
const gridScale = useValue(1);
const lineHeight = useComputedValue(
() => gridScale.current * LINE_HEIGHT * 4,
[gridScale]
);
// ...
return (
// ...
<Canvas>
<Text x={10} y={lineHeight} text={'...'}/>
</Canvas>
) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been playing around with
useComputedValue
. If I use the output directly on a property in the Canvas, it works great, but if I perform any math on it, everything stops with the error: 'No default value'. For example:This throws the 'No default value' error. When I change it to
y={lineHeight.current * 4}
, it renders fine, but it doesn't change whenlineHeight
changes. Since all of this is going to be dynamic (I'm rendering a list of items and the user can pinch to zoom), I can't create a separate useComputedValue hook for each text element.Beta Was this translation helpful? Give feedback.
All reactions