Skip to content

Commit a7ddd7b

Browse files
brunolemosnecolas
authored andcommitted
[fix] SafeAreaView ref supports setNativeProps
facebook/react-native#24589 Close #1407
1 parent 8f5e7d4 commit a7ddd7b

File tree

1 file changed

+15
-19
lines changed
  • packages/react-native-web/src/exports/SafeAreaView

1 file changed

+15
-19
lines changed

packages/react-native-web/src/exports/SafeAreaView/index.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,24 @@ import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
1212
import React from 'react';
1313
import StyleSheet from '../StyleSheet';
1414
import View from '../View';
15-
import ViewPropTypes, { type ViewProps } from '../ViewPropTypes';
15+
import { type ViewProps } from '../ViewPropTypes';
1616

17-
class SafeAreaView extends React.Component<ViewProps> {
18-
static displayName = 'SafeAreaView';
17+
const SafeAreaView = React.forwardRef<View, ViewProps>((props: ViewProps, ref) => {
18+
const { style, ...rest } = props;
1919

20-
static propTypes = {
21-
...ViewPropTypes
22-
};
20+
return (
21+
<View
22+
{...rest}
23+
ref={ref}
24+
style={StyleSheet.compose(
25+
styles.root,
26+
style
27+
)}
28+
/>
29+
);
30+
});
2331

24-
render() {
25-
const { style, ...rest } = this.props;
26-
return (
27-
<View
28-
{...rest}
29-
style={StyleSheet.compose(
30-
styles.root,
31-
style
32-
)}
33-
/>
34-
);
35-
}
36-
}
32+
SafeAreaView.displayName = 'SafeAreaView';
3733

3834
const cssFunction: 'constant' | 'env' = (function() {
3935
if (

0 commit comments

Comments
 (0)