FormidableLabs / FormidableLabs/victory-native-xl
actionsRef causes reanimated warning: modify object already passed to worklet
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 109
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 3
Description
### Prerequisites
- [x] I have searched the open [issues](https://www.github.com/FormidableLabs/victory-native-xl/issues) to make sure I'm not opening a duplicate issue
- [x] I have read through the [docs](https://www.formidable.com/open-source/victory-native-xl/docs) before asking a question
- [x] I am using the latest version of victory-native-xl
### Describe Your Environment
**What version of victory-native-xl are you using?** `victory-native@41.17.1`
**What version of React and React Native are you using?** `react@18.3.1` `react-native@0.76.9`
**What version of Reanimated and React Native Skia are you using?** `react-native-reanimated@~3.16.1` `@shopify/react-native-skia@1.10.1`
**Are you using Expo or React Native CLI?** `Expo`
**What platform are you on?** (e.g., iOS, Android) `iOS, Android and Web`
### Describe the Problem
When I pass `actionsRef` to `CartesianChart` I get this warning in console:
```console
WARN [Reanimated] Tried to modify key `current` of an object which has been already passed to a worklet. See
https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-modify-key-of-an-object-which-has-been-converted-to-a-shareable
for more details.
```
The warning is directly caused by this line in `CartesianChart.tsx`: https://github.com/FormidableLabs/victory-native-xl/blob/1d8a2b5da58f2cc5652e9d52fab3ea53283033f3/lib/src/cartesian/CartesianChart.tsx#L365
Although `actionsRef` is not directly used in a worklet it's trying to set a worklet as a property of current object of the ref, so that **might** be the cause of the warning, I'm not sure as I'm not that experienced with reanimated.
But I know that if I comment out those lines or change the ref to a shared-value the warning goes away.
I can confirm that I'm not using `actionsRef` inside a _worklet_ in my code.
**Expected behavior:** There should be no warning
**Actual behavior:** There is warning
### Additional Information
Contributor guide
Research direction
Start in lib/src/cartesian/CartesianChart.tsx at the line around 365 that assigns the actionsRef value. Reproduce the warning with actionsRef enabled using the listed React Native, Reanimated, and Skia versions, then verify that the warning no longer appears while the expected actionsRef behavior remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- frontend, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100