Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions docs/_integration-with-existing-apps-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ AppRegistry.registerComponent('HelloWorld', () => App);
Let's create an `App.tsx` file. This is a [TypeScript](https://www.typescriptlang.org/) file that can have [JSX](<https://en.wikipedia.org/wiki/JSX_(JavaScript)>) expressions. It contains the root React Native component that we will integrate into our iOS application (<RNTemplateRepoLink href="template/App.tsx">link</RNTemplateRepoLink>):

```tsx
import React from 'react';
import {type JSX} from 'react';
import {
SafeAreaView,
ScrollView,
Expand All @@ -177,7 +177,7 @@ import {
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

function App(): React.JSX.Element {
function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
Expand Down
5 changes: 2 additions & 3 deletions docs/_integration-with-existing-apps-kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ AppRegistry.registerComponent('HelloWorld', () => App);
Let's create an `App.tsx` file. This is a [TypeScript](https://www.typescriptlang.org/) file that can have [JSX](<https://en.wikipedia.org/wiki/JSX_(JavaScript)>) expressions. It contains the root React Native component that we will integrate into our Android application (<RNTemplateRepoLink href="template/App.tsx">link</RNTemplateRepoLink>):

```tsx
import React from 'react';
import {type JSX} from 'react';
import {
SafeAreaView,
ScrollView,
Expand All @@ -202,15 +202,14 @@ import {
useColorScheme,
View,
} from 'react-native';

import {
Colors,
DebugInstructions,
Header,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

function App(): React.JSX.Element {
function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
Expand Down
2 changes: 1 addition & 1 deletion docs/accessibilityinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Sometimes it's useful to know whether or not the device has a screen reader that
## Example

```SnackPlayer name=AccessibilityInfo%20Example&supportedPlatforms=android,ios
import React, {useState, useEffect} from 'react';
import {useState, useEffect} from 'react';
import {AccessibilityInfo, Text, StyleSheet} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
2 changes: 1 addition & 1 deletion docs/actionsheetios.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Displays native to iOS [Action Sheet](https://developer.apple.com/design/human-i
## Example

```SnackPlayer name=ActionSheetIOS%20Example&supportedPlatforms=ios
import React, {useState} from 'react';
import {useState} from 'react';
import {ActionSheetIOS, Button, StyleSheet, Text} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
1 change: 0 additions & 1 deletion docs/activityindicator.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Displays a circular loading indicator.
## Example

```SnackPlayer name=ActivityIndicator%20Example
import React from 'react';
import {ActivityIndicator, StyleSheet} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
2 changes: 0 additions & 2 deletions docs/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ This is an API that works both on Android and iOS and can show static alerts. Al
## Example

```SnackPlayer name=Alert%20Example&supportedPlatforms=ios,android
import React from 'react';
import {StyleSheet, Button, Alert} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down Expand Up @@ -81,7 +80,6 @@ The cancel event can be handled by providing an `onDismiss` callback property in
### Example <div className="label android">Android</div>

```SnackPlayer name=Alert%20Android%20Dissmissable%20Example&supportedPlatforms=android
import React from 'react';
import {StyleSheet, Button, Alert} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
1 change: 0 additions & 1 deletion docs/animated.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Don't modify the animated value directly. You can use the [`useRef` Hook](https:
The following example contains a `View` which will fade in and fade out based on the animated value `fadeAnim`

```SnackPlayer name=Animated%20Example
import React from 'react';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
import {
Animated,
Expand Down
2 changes: 1 addition & 1 deletion docs/animatedvaluexy.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ title: Animated.ValueXY
## Example

```SnackPlayer name=Animated.ValueXY%20Example
import React, {useRef} from 'react';
import {useRef} from 'react';
import {Animated, PanResponder, StyleSheet} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
11 changes: 5 additions & 6 deletions docs/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For example, a container view that fades in when it is mounted may look like thi
<TabItem value="javascript">

```SnackPlayer ext=js
import React, {useEffect, useRef} from 'react';
import {useEffect, useRef} from 'react';
import {Animated, Text, View} from 'react-native';

const FadeInView = props => {
Expand Down Expand Up @@ -74,12 +74,12 @@ export default () => {
<TabItem value="typescript">

```SnackPlayer ext=tsx
import React, {useEffect, useRef, type PropsWithChildren} from 'react';
import {useEffect, useRef, type PropsWithChildren, type FC} from 'react';
import {Animated, Text, View, type ViewStyle} from 'react-native';

type FadeInViewProps = PropsWithChildren<{style: ViewStyle}>;

const FadeInView: React.FC<FadeInViewProps> = props => {
const FadeInView: FC<FadeInViewProps> = props => {
const fadeAnim = useRef(new Animated.Value(0)).current; // Initial value for opacity: 0

useEffect(() => {
Expand Down Expand Up @@ -309,7 +309,6 @@ The following example implements a horizontal scrolling carousel where the scrol
#### ScrollView with Animated Event Example

```SnackPlayer name=Animated&supportedPlatforms=ios,android
import React from 'react';
import {
ScrollView,
Text,
Expand Down Expand Up @@ -452,7 +451,7 @@ onPanResponderMove={Animated.event(
#### PanResponder with Animated Event Example

```SnackPlayer name=Animated
import React, {useRef} from 'react';
import {useRef} from 'react';
import {Animated, View, StyleSheet, PanResponder, Text} from 'react-native';

const App = () => {
Expand Down Expand Up @@ -593,7 +592,7 @@ UIManager.setLayoutAnimationEnabledExperimental(true);
```

```SnackPlayer name=LayoutAnimations
import React, {useState} from 'react';
import {useState} from 'react';
import {
NativeModules,
LayoutAnimation,
Expand Down
2 changes: 1 addition & 1 deletion docs/appstate.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you are using the legacy architecture, `currentState` will be `null` at launc
:::

```SnackPlayer name=AppState%20Example
import React, {useRef, useState, useEffect} from 'react';
import {useRef, useState, useEffect} from 'react';
import {AppState, StyleSheet, Text} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
2 changes: 1 addition & 1 deletion docs/backhandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ subscription.remove();
The following example implements a scenario where you confirm if the user wants to exit the app:

```SnackPlayer name=BackHandler&supportedPlatforms=android
import React, {useEffect} from 'react';
import {useEffect} from 'react';
import {Text, StyleSheet, BackHandler, Alert} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
1 change: 0 additions & 1 deletion docs/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ If this button doesn't look right for your app, you can build your own button us
## Example

```SnackPlayer name=Button%20Example&ext=js
import React from 'react';
import {StyleSheet, Button, View, Text, Alert, Platform} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
1 change: 0 additions & 1 deletion docs/communication-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class MainActivity : ReactActivity() {
</Tabs>

```tsx
import React from 'react';
import {View, Image} from 'react-native';

export default class ImageBrowserApp extends React.Component {
Expand Down
1 change: 0 additions & 1 deletion docs/communication-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
```

```tsx
import React from 'react';
import {View, Image} from 'react-native';

export default class ImageBrowserApp extends React.Component {
Expand Down
2 changes: 1 addition & 1 deletion docs/dimensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If you are targeting foldable devices or devices which can change the screen siz
## Example

```SnackPlayer name=Dimensions%20Example
import React, {useState, useEffect} from 'react';
import {useState, useEffect} from 'react';
import {StyleSheet, Text, Dimensions} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down
6 changes: 3 additions & 3 deletions docs/document-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Document nodes
Document nodes represent a complete native view tree. Apps using native navigation would provide a separate document node for each screen. Apps not using native navigation would generally provide a single document for the whole app (similar to single-page apps on Web).

```SnackPlayer ext=js&name=Document%20instance%20example
import * as React from 'react';
import {useEffect, useRef} from 'react';
import {Text, TextInput, View} from 'react-native';

function MyComponent(props) {
Expand All @@ -19,9 +19,9 @@ function MyComponent(props) {
}

export default function AccessingDocument() {
const ref = React.useRef(null);
const ref = useRef(null);

React.useEffect(() => {
useEffect(() => {
// Get the main text input in the screen and focus it after initial load.
const element = ref.current;
const doc = element.ownerDocument;
Expand Down
4 changes: 2 additions & 2 deletions docs/drawerlayoutandroid.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ React component that wraps the platform `DrawerLayout` (Android only). The Drawe
<TabItem value="javascript">

```SnackPlayer name=DrawerLayoutAndroid%20Component%20Example&supportedPlatforms=android&ext=js
import React, {useRef, useState} from 'react';
import {useRef, useState} from 'react';
import {Button, DrawerLayoutAndroid, Text, StyleSheet} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down Expand Up @@ -86,7 +86,7 @@ export default App;
<TabItem value="typescript">

```SnackPlayer name=DrawerLayoutAndroid%20Component%20Example&supportedPlatforms=android&ext=tsx
import React, {useRef, useState} from 'react';
import {useRef, useState} from 'react';
import {
Button,
DrawerLayoutAndroid,
Expand Down
4 changes: 2 additions & 2 deletions docs/easing.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The following helpers are used to modify other easing functions.
<TabItem value="javascript">

```SnackPlayer name=Easing%20Demo&ext=js
import React, {useRef} from 'react';
import {useRef} from 'react';
import {
Animated,
Easing,
Expand Down Expand Up @@ -209,7 +209,7 @@ export default App;
<TabItem value="typescript">

```SnackPlayer name=Easing%20Demo&ext=tsx
import React, {useRef} from 'react';
import {useRef} from 'react';
import {
Animated,
Easing,
Expand Down
10 changes: 5 additions & 5 deletions docs/element-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Element nodes represent native components in the native view tree (similar to [E
They are provided by all native components, and by many built-in components, via refs:

```SnackPlayer ext=js&name=Element%20instances%20example
import * as React from 'react';
import { View, SafeAreaView, StyleSheet, Text } from 'react-native';
import {useEffect, useRef, useState} from 'react';
import {View, SafeAreaView, StyleSheet, Text} from 'react-native';

const ViewWithRefs = () => {
const ref = React.useRef(null);
const [viewInfo, setViewInfo] = React.useState('');
const ref = useRef(null);
const [viewInfo, setViewInfo] = useState('');

React.useEffect(() => {
useEffect(() => {
// `element` is an object implementing the interface described here.
const element = ref.current;
const rect = JSON.stringify(element.getBoundingClientRect());
Expand Down
1 change: 0 additions & 1 deletion docs/fabric-native-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ This guide shows you how to create a Native Component that only works with the N
Finally, you can use the new component in your app. Update your generated `App.tsx` to:

```javascript title="Demo/App.tsx"
import React from 'react';
import {Alert, StyleSheet, View} from 'react-native';
import WebView from './specs/WebViewNativeComponent';

Expand Down
6 changes: 2 additions & 4 deletions docs/flatlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ If you need section support, use [`<SectionList>`](sectionlist.md).
<TabItem value="javascript">

```SnackPlayer name=Simple%20FlatList%20Example&ext=js
import React from 'react';
import {View, FlatList, StyleSheet, Text, StatusBar} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down Expand Up @@ -86,7 +85,6 @@ export default App;
<TabItem value="typescript">

```SnackPlayer name=Simple%20FlatList%20Example&ext=tsx
import React from 'react';
import {View, FlatList, StyleSheet, Text, StatusBar} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

Expand Down Expand Up @@ -158,7 +156,7 @@ More complex, selectable example below.
<TabItem value="javascript">

```SnackPlayer name=flatlist-selectable&ext=js
import React, {useState} from 'react';
import {useState} from 'react';
import {
FlatList,
StatusBar,
Expand Down Expand Up @@ -242,7 +240,7 @@ export default App;
<TabItem value="typescript">

```SnackPlayer name=flatlist-selectable&ext=tsx
import React, {useState} from 'react';
import {useState} from 'react';
import {
FlatList,
StatusBar,
Expand Down
Loading