Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mutable value read/write during render warning #6310

Merged
merged 13 commits into from
Aug 28, 2024

Conversation

MatiPl01
Copy link
Member

@MatiPl01 MatiPl01 commented Jul 22, 2024

Summary

This PR adds warnings shown when the SharedValue .value property is accessed (read or written) while the component is being rendered.
The initial render is ignored as all reanimated hooks are executed for the first time during the initial render (e.g. useAnimatedStyle builds the initial component style).

Test plan

  • open the Invalid read/write during render example in the example app,
  • press on the Re-render button to trigger re-render, which will access .value property of the shared value from the component function body,
  • see warnings about invalid read and invalid write

@MatiPl01 MatiPl01 self-assigned this Jul 22, 2024
@MatiPl01 MatiPl01 marked this pull request as ready for review July 30, 2024 10:20
@MatiPl01 MatiPl01 requested a review from tomekzaw July 30, 2024 10:43
Copy link
Member

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MatiPl01 MatiPl01 force-pushed the @matipl01/mutable-value-access-during-render-warning branch from a15a12b to 70fd267 Compare August 13, 2024 11:53
@MatiPl01 MatiPl01 changed the base branch from main to @matipl01/configurable-logger August 13, 2024 11:54
@MatiPl01 MatiPl01 force-pushed the @matipl01/mutable-value-access-during-render-warning branch from 70fd267 to d538f1e Compare August 13, 2024 11:59
@MatiPl01 MatiPl01 force-pushed the @matipl01/mutable-value-access-during-render-warning branch from d538f1e to 837c3b4 Compare August 13, 2024 22:13
@MatiPl01 MatiPl01 force-pushed the @matipl01/configurable-logger branch 2 times, most recently from 0e9eec1 to e4bca1d Compare August 26, 2024 12:22
github-merge-queue bot pushed a commit that referenced this pull request Aug 28, 2024
## Summary

This PR adds a possibility to customize log level via the `level`
property (limit to just see errors or show errors and warnings) and
enable/disable strict mode (via `strict` property), which will be useful
for changes implemented in
[this](#6310)
PR to show invalid `.value` access warnings only in the strict mode.

## Example recording


https://github.com/user-attachments/assets/232d3b69-d99c-4114-989f-967d9d8c9e22


## Test plan

- Open `EmptyExample` (which will be reverted to the original
implementation before merging this PR),
- Change logger settings (e.g. the `level` property) via
`Animated.configureLogger`,

---------

Co-authored-by: Tomasz Żelawski <40713406+tjzel@users.noreply.github.com>
Base automatically changed from @matipl01/configurable-logger to main August 28, 2024 15:13
@MatiPl01 MatiPl01 force-pushed the @matipl01/mutable-value-access-during-render-warning branch from 837c3b4 to f87cc00 Compare August 28, 2024 15:40
@MatiPl01 MatiPl01 force-pushed the @matipl01/mutable-value-access-during-render-warning branch from 880a0f5 to 5a7258c Compare August 28, 2024 15:44
@MatiPl01 MatiPl01 added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit f34b304 Aug 28, 2024
8 checks passed
@MatiPl01 MatiPl01 deleted the @matipl01/mutable-value-access-during-render-warning branch August 28, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants