Skip to content

Commit 5ed58f9

Browse files
committed
docs: forwardRef for FlashList+renderScrollComponent
1 parent 13dfb32 commit 5ed58f9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

docs/docs/api/components/keyboard-aware-scroll-view.mdx

+7-4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ Unlike original [react-native-keyboard-aware-scroll-view](https://github.com/APS
124124
If you want to integrate it with your custom virtualization list, you can pass `renderScrollComponent` prop like:
125125

126126
```tsx
127-
import { FlatList } from "react-native";
127+
import React from "react";
128+
import { FlatList, ScrollView, ScrollViewProps } from "react-native";
128129
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
129130

130131
<FlatList
@@ -135,9 +136,11 @@ import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
135136

136137
import { FlashList } from "@shopify/flash-list";
137138

138-
<FlashList
139-
renderScrollComponent={(props) => <KeyboardAwareScrollView {...props} />}
140-
/>;
139+
const RenderScrollComponent = React.forwardRef<ScrollView, ScrollViewProps>(
140+
(props, ref) => <KeyboardAwareScrollView {...props} ref={ref} />,
141+
);
142+
143+
<FlashList renderScrollComponent={RenderScrollComponent} />;
141144
```
142145

143146
<details>

docs/versioned_docs/version-1.16.0/api/components/keyboard-aware-scroll-view.mdx

+7-4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ Unlike original [react-native-keyboard-aware-scroll-view](https://github.com/APS
124124
If you want to integrate it with your custom virtualization list, you can pass `renderScrollComponent` prop like:
125125

126126
```tsx
127-
import { FlatList } from "react-native";
127+
import React from "react";
128+
import { FlatList, ScrollView, ScrollViewProps } from "react-native";
128129
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
129130

130131
<FlatList
@@ -135,9 +136,11 @@ import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
135136

136137
import { FlashList } from "@shopify/flash-list";
137138

138-
<FlashList
139-
renderScrollComponent={(props) => <KeyboardAwareScrollView {...props} />}
140-
/>;
139+
const RenderScrollComponent = React.forwardRef<ScrollView, ScrollViewProps>(
140+
(props, ref) => <KeyboardAwareScrollView {...props} ref={ref} />,
141+
);
142+
143+
<FlashList renderScrollComponent={RenderScrollComponent} />;
141144
```
142145

143146
<details>

0 commit comments

Comments
 (0)