Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert InputAccessoryView to function component #42883

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -85,27 +85,25 @@ type Props = $ReadOnly<{|
backgroundColor?: ?ColorValue,
|}>;

class InputAccessoryView extends React.Component<Props> {
render(): React.Node {
if (Platform.OS === 'ios') {
if (React.Children.count(this.props.children) === 0) {
return null;
}

return (
<RCTInputAccessoryViewNativeComponent
style={[this.props.style, styles.container]}
nativeID={this.props.nativeID}
backgroundColor={this.props.backgroundColor}>
{this.props.children}
</RCTInputAccessoryViewNativeComponent>
);
} else {
console.warn('<InputAccessoryView> is only supported on iOS.');
const InputAccessoryView: React.AbstractComponent<Props> = (props: Props) => {
if (Platform.OS === 'ios') {
if (React.Children.count(props.children) === 0) {
return null;
}

return (
<RCTInputAccessoryViewNativeComponent
style={[props.style, styles.container]}
nativeID={props.nativeID}
backgroundColor={props.backgroundColor}>
{props.children}
</RCTInputAccessoryViewNativeComponent>
);
} else {
console.warn('<InputAccessoryView> is only supported on iOS.');
return null;
}
}
};

const styles = StyleSheet.create({
container: {
Original file line number Diff line number Diff line change
@@ -2405,6 +2405,18 @@ declare export default HostComponent<NativeProps>;
"
`;

exports[`public API should not change unintentionally Libraries/Components/TextInput/InputAccessoryView.js 1`] = `
"type Props = $ReadOnly<{|
+children: React.Node,
nativeID?: ?string,
style?: ?ViewStyleProp,
backgroundColor?: ?ColorValue,
|}>;
declare const InputAccessoryView: React.AbstractComponent<Props>;
declare module.exports: InputAccessoryView;
"
`;

exports[`public API should not change unintentionally Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js 1`] = `
"export * from \\"../../../src/private/specs/components/RCTInputAccessoryViewNativeComponent\\";
declare export default typeof RCTInputAccessoryViewNativeComponent;
Loading