Skip to content

Commit

Permalink
Change Alert to console.log in new docs (#2670)
Browse files Browse the repository at this point in the history
## Description

Some examples in our docs use `Alert.alert`, even though callbacks in new api are automatically workletized. They won't work, because there's no way to access `Alert` on UI thread.

Fixes #2667 

## Test plan

Checked that both `LongPress` and `Tap` pages were updated.
  • Loading branch information
m-bert authored Nov 6, 2023
1 parent ff3b820 commit 8d3d5e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/docs/gestures/long-press-gesture.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ Duration of the long press (time since the start of the gesture), expressed in m
## Example

```jsx
import { View, StyleSheet, Alert } from 'react-native';
import { View, StyleSheet } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';

export default function App() {
const longPressGesture = Gesture.LongPress().onEnd((e, success) => {
if (success) {
Alert.alert(`Long pressed for ${e.duration} ms!`);
console.log(`Long pressed for ${e.duration} ms!`);
}
});

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/gestures/tap-gesture.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,21 @@ Y coordinate, expressed in points, of the current position of the pointer (finge
## Example

```jsx
import { View, Alert, StyleSheet } from 'react-native';
import { View, StyleSheet } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';

export default function App() {
const singleTap = Gesture.Tap()
.maxDuration(250)
.onStart(() => {
Alert.alert('Single tap!');
console.log('Single tap!');
});

const doubleTap = Gesture.Tap()
.maxDuration(250)
.numberOfTaps(2)
.onStart(() => {
Alert.alert('Double tap!');
console.log('Double tap!');
});

return (
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/under-the-hood/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Each state has its own description below.
We can monitor a handler's state changes by using the [`onHandlerStateChange`](/docs/gesture-handlers/common-gh#onhandlerstatechange) callback and the destructured `nativeEvent` argument passed to it.
This can be done by comparing the `nativeEvent`'s [`state`](/docs/gesture-handlers/common-gh#state) attribute to one of the constants exported under the `State` object (see example below).

```
```jsx
import { State, LongPressGestureHandler } from 'react-native-gesture-handler';

class Demo extends Component {
Expand Down

0 comments on commit 8d3d5e0

Please sign in to comment.