我有一个reanimated
ReadOnly<SharedValue<boolean>>
从另一个派生的SharedValue
:
const solidHeader = useDerivedValue(() => {
return top.value <= -(height / 2);
});
我想在solidHeader.value
更改时调用一个 RN 函数(未恢复)。具体来说,我想更新我react-navigation
的标题透明度:
// This doesn't get called when `solidHeader.value` is updated in reanimated's thread
useEffect(() => {
navigation.setOptions({headerTransparent: !solidHeader.value});
}, [solidHeader.value]);
我尝试了以下“似乎”是正确的方法,但后来我得到了错误
Reanimated: Animated.call node args should be an array with elements of type AnimatedNode. One or more of them are not AnimatedNodes
useCode(() => {
return call([solidHeader], (solidHeader) => {
console.warn(solidHeader);
navigation.setOptions({
headerTransparent: !solidHeader,
});
});
}, [solidHeader]);
我正在实现的目标是可能的吗?