Skip to content

Commit 49c89d0

Browse files
committed
fix: call playIfNeeded on orientation change
1 parent 7e31608 commit 49c89d0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

example/src/pages/ResponsiveLayouts.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { useState, useRef } from 'react';
1+
import { useState, useRef, useEffect } from 'react';
22
import {
33
View,
44
Text,
55
StyleSheet,
66
Button,
77
ActivityIndicator,
8+
useWindowDimensions,
89
} from 'react-native';
910
import {
1011
Fit,
@@ -20,6 +21,11 @@ export default function ResponsiveLayoutsExample() {
2021
);
2122
const [scaleFactor, setScaleFactor] = useState(4.0);
2223
const riveRef = useRef<RiveViewRef>(null);
24+
const { width, height } = useWindowDimensions();
25+
26+
useEffect(() => {
27+
riveRef.current?.playIfNeeded();
28+
}, [width, height]);
2329

2430
const increaseScale = () => {
2531
setScaleFactor((prev) => prev + 0.5);

0 commit comments

Comments
 (0)