Skip to content

Commit 0300fb3

Browse files
Inbal-Tishethanshar
authored andcommitted
Adding onOrientationChange event to trigger re-render on tablets when 'fullWidth' is passed (#565)
1 parent 5837a07 commit 0300fb3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

demo/src/screens/componentScreens/ButtonsScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default class ButtonsScreen extends DemoScreen {
6565
return (
6666
<View useSafeArea>
6767
{!!snippet && <SnippetBlock snippet={snippet} onClose={() => this.hideSnippet()}/>}
68-
<ScrollView>
68+
<ScrollView showsVerticalScrollIndicator={false}>
6969
<View centerH>
7070
<Text style={styles.title}>Buttons</Text>
7171

src/components/button/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ export default class Button extends PureBaseComponent {
176176
}
177177
}
178178

179+
componentDidMount() {
180+
Constants.addDimensionsEventListener(this.onOrientationChanged);
181+
}
182+
183+
componentWillUnmount() {
184+
Constants.removeDimensionsEventListener(this.onOrientationChanged);
185+
}
186+
187+
onOrientationChanged = () => {
188+
if (Constants.isTablet && this.props.fullWidth) {
189+
// only to trigger re-render
190+
this.setState({isLandscape: Constants.isLandscape});
191+
}
192+
};
193+
179194
// This method will be called more than once in case of layout change!
180195
onLayout = event => {
181196
const height = event.nativeEvent.layout.height;

0 commit comments

Comments
 (0)