Skip to content

Commit 3fa10e1

Browse files
authored
docs: limitations (#20)
1 parent b83f704 commit 3fa10e1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,41 @@ bottomSheetRef.current.snapTo(0)
183183

184184
`bottomSheetRef` refers to the [`ref`](https://reactjs.org/docs/react-api.html#reactcreateref) passed to the `ScrollBottomSheet` component.
185185

186+
## Limitations
187+
At the moment, the component does not support updating snap points via state, something you may want to achieve when changing device orientation for instance. A temporary workaround is to leverage React keys to force a re-mount of the component. This is some illustrative code to give you an idea how you could handle an orientation change with keys:
188+
189+
```js
190+
import { useDimensions } from '@react-native-community/hooks'
191+
192+
const useOrientation = () => {
193+
const { width, height } = useDimensions().window;
194+
195+
if (height > width) {
196+
return 'portrait'
197+
}
198+
199+
return 'landscape'
200+
}
201+
202+
const OrientationAwareBS = () => {
203+
const orientation = useOrientation();
204+
const snapPoints = {
205+
portrait: [...],
206+
landscape: [...]
207+
}
208+
209+
return (
210+
<ScrollBottomSheet
211+
key={orientation}
212+
componentType="FlatList"
213+
snapPoints={snapPoints[orientation]}
214+
initialSnapIndex={2}
215+
...
216+
/>
217+
);
218+
}
219+
```
220+
186221
## Example
187222
There is an Expo example application that you can play with to get a good grasp on the different customisation options. In case of Android, you can directly open the project [here](https://expo.io/@rgommezz/react-native-scroll-bottom-sheet-example). For iOS, head to the [example folder](https://github.com/rgommezz/react-native-scroll-bottom-sheet/tree/master/example) and run the project locally:
188223

0 commit comments

Comments
 (0)