Comments (5)
The compiler should actually compile this fine, I think the healthcheck script doesn't track the reanimated import and turn on the correct type information. This should just be a fix in the health check script.
from react.
An alternative would be to use your own helper for assigning the value. Instead of x.value = y
, create your own updateSharedValue(sharedValue, value)
helper function and call it.
from react.
Thanks for posting. We've discussed this previously with the Reanimated team.
React requires that values returned from hooks are immutable. This is because React's reactivity model is fundamentally based on immutability, both for developer reasoning and to enable features such as concurrent rendering, where React may render multiple distinct versions of your UI with different base states.
The one exception to this rule is the ref type (created with createRef()
or useRef()
). They are the escape hatch for when you need a value that can be directly mutated, rather than copying (spreading) and changing the new version as we do with state values. The reason that refs can be "safely" mutated is that they can't be accessed during render, which helps developers avoid accidentally rendering stale results.
Our recommendation for APIs such as Reanimated's SharedValue API:
- Disallow access to the
.value
during rendering, to help developers avoid accidentally reading the value outside of Reanimated APIs which will subscribe for updates - Use a function for updates instead of property assignment, Eg
setValue(sharedValue, value)
instead ofsharedValue.value = value
.
from react.
Thankโs @josephsavona for the explanation.
If I understand correctly, as react-native developer we have to wait some api design update by react-native-reanimated team to be able to use react-compiler with our component that use x.value = y;
syntax ?
from react.
Thank you for the insight ๐
from react.
Related Issues (20)
- ghgh
- [spam]
- [spam]
- [spam]
- [spam]
- Bug: Hydration fails when async script is located outside head tag HOT 6
- [React 19]
- Bug: onSelect does not fire when contentEditable is set to "plaintext-only" HOT 1
- [React 19]
- Unable to select color using voice access commands. HOT 1
- [spam]
- [spam]
- Bug: Updater function of set state in promise.then clause of useEffect are called twice and replacing state before promise.then doesn't work as expected. HOT 4
- [Compiler Bug]: Mutating a ref passed as argument from a hook warns HOT 3
- [React 19]
- Bug: Changes to marker references post-render are not updating in Safari
- [React 19] useSyncExternalStore shim might break HOT 8
- [React 19] `use` is significantly slower in some scenarios than throwing a Promise HOT 10
- Bug: useState is not getting updated inside Event Listener (Webrtc DataChannel). HOT 2
- [React 19] Controlled number input does not update defaultValue when value prop has changed HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.