I have the simplest example possible with useDerivedValue
:
A SharedValue
that is modified when scrolling.
A derived boolean
value based on this scroll position
const isShown = useDerivedValue(() => {
console.log('y', currentPositionY.value);
return currentPositionY.value > 40;
}, [currentPositionY]);
The y
is logged and modified as it should.
A component that should display a different text based on this boolean:
const TestC = ({ isShown }: { isShown: SharedValue<boolean> }) => {
console.log('isS', isShown.value);
if (isShown.value) {
return <Text>shown</Text>;
} else {
return <Text>not shown</Text>;
}
};
But the TestC
component is not updated following the derived value.
What am I missing?