-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary The babel plugin transformed the code and added some helper code, it uses `new Error()` to get the call stack. this works in general unless you have a variable called `Error` in the local scope, in this case, It references the wrong Object. this PR uses `global.Error` to avoid this. `'Date'` is duplicated in this `global` array, and I removed the second one. ## Test plan ```jsx import { useState } from 'react'; import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated'; import Error from './components/Error'; // imported an arrow function component named 'Error' const App = () => { const [hasError, setHasError] = useState(false); const offset = useSharedValue(0); // `new Error()` not working here, because `Error` reference to the function component, it's a arrow function, not a function or class const animatedStyles = useAnimatedStyle(() => ({ transform: [{ translateX: offset.value * 255 }] }), []); if (hasError) return <Error />; return <Animated.View style={animatedStyles} />; }; ``` --------- Co-authored-by: Tomasz Żelawski <40713406+tjzel@users.noreply.github.com>
- Loading branch information
1 parent
79b699a
commit 576b714
Showing
2 changed files
with
35 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters