Should useDerivedValue cause a rerender?
See original GitHub issueDescription
If I format a date on the ui thread like so…
const date = useDerivedValue(() => {
const d = interpolate(translation.x.value, [0, width], [MIN, MAX]);
return formatDateOnUI(d);
});
return <Text>{date}</Text>
In this example date will update (can check by logging d before return), however it will not update the UI… I can hack around this by calling some setState with runOnJS and that triggers a re-render but of course affects fps on the JS thread
Package versions
- React: 16.13.1
- React Native: ~0.63.3
- React Native Reanimated: 2.0.0-rc.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (8 by maintainers)
Top Results From Across the Web
useDerivedValue | React Native Reanimated
This hook allows for creating shared value reference that can change in ... cause this hook to receive updated values during rerender of...
Read more >Set state with same value using hooks will cause a rerender?
It won't re-render the component if you call setState with the same value. Try this out: import React, { useState, useEffect } from...
Read more >why my component are always rerender although I use memo
This is the correct answer. handleAddOrRemoveFromWishList is changing every time, so memo sees it as changed props and re-renders. If you use ...
Read more >When does React re-render components? - Felix Gerschau
Real DOM updates are slow because they cause an actual re-draw of the UI ... In React class components, you can force a...
Read more >Shared Values | React Native Reanimated
If you are familiar with React Native's Animated API you can compare them to ... and in order to read the data we...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think that does not break a thing, however, it would be inefficient as it overwrites collections on both, js and the native side.
@anastely, you can add it wherever you want, you only want to ensure it runs only once.
index.jsorApp.jsor any standalone configuration file that is included there is fine. Using that in a component file (outside of component definition) is also fine but you may prefer a more “global” place to keep your configs in.