Fix incorrect useAnimatedValue usage in Animated documentation
維護者通常 1 天內回覆
評估
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 新手友好度
- 85/100
- Issue 類型
- 文件
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- react-native
研究方向
在 react-native-website 儲存庫中找出 Animated API 文件頁面,找到錯誤匯入並使用 useAnimatedValue 的程式碼範例,將 useAnimatedValue(0) 替換為 new Animated.Value(0),並移除未使用的 useAnimatedValue 匯入,接著確認範例執行時不會發生回報的執行階段錯誤。
由索引模型根據 Issue 內容生成。
描述
Description
The Animated documentation currently contains an incorrect code example that imports and uses useAnimatedValue from react-native.
The example fails at runtime because useAnimatedValue is not available from react-native in the version used by the documentation.
This PR fixes the example by replacing useAnimatedValue(0) with new Animated.Value(0) and removing useAnimatedValue from the imports.
What is the problem?
The example in the Animated documentation imports useAnimatedValue from react-native and uses it to initialize the animated value.
This results in a runtime error because useAnimatedValue is not available from react-native:
TypeError: (0, _reactNative.useAnimatedValue) is not a function
As a result, users following the official documentation are unable to run the example as provided.
How can we address it?
Replace useAnimatedValue(0) with new Animated.Value(0) and remove useAnimatedValue from the react-native imports.
No other changes to the example are required.
Why is it important?
The example is part of the official React Native documentation, so users may reasonably expect the code to work when copied directly into a project.
A runtime error in a basic Animated example can be particularly confusing for developers learning or getting started with React Native.
Who needs this?
This is relevant to developers using the React Native Animated API, especially developers learning React Native or following the official documentation examples.
When should this happen (use version numbers if needed)?
This should be fixed as soon as possible so that the Animated documentation provides a working example.
- 主要語言
- MDX
- 星號
- 2.2k
- 分支
- 6.4k
- 平均合併
- 13 小時 6 分鐘
- 30 天內合併 PR
- 28
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
react/react-native-website 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
react/react-native-website#5258 ·
維護者通常 1 天內回覆
-
Docs: distinguish Fast Refresh effect reruns from Strict Mode checks可能已有人在做 @walitemuri 於 25 天前認領。 未關閉
難度 1/5 1-3 小時 新手友好度 88/100
react/react-native-website#5217 ·
維護者通常 1 天內回覆
-
Integration with Existing Apps: Podfile example does not use `use_react_native!`, is incomplete可能已有人在做 @mhjacobson 於 1702 天前認領。 未關閉👋 Good first issue
難度 1/5 1 小時以內 新手友好度 78/100
react/react-native-website#2958 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 30/100
react/react-native-website#5259 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 48/100
react/react-native-website#5216 · 1 則留言 ·
維護者通常 1 天內回覆
查看 react/react-native-website 的全部 Issue
相似的 Issue
-
mxl-compile: пример заполнения ячеек отклоняется Unica可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 1/5 1-3 小時 新手友好度 91/100
IngvarConsulting/unica#1301 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
siyuan-note/siyuan#20313 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 82/100
gofish-graphics/gofish-graphics#1084 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 76/100
ethereum/execution-apis#935 ·
維護者通常 1 天內回覆