Skip to content

Commit

Permalink
forward ref from NewInput to PlainInput
Browse files Browse the repository at this point in the history
  • Loading branch information
buoyad committed Sep 17, 2018
1 parent 7e01465 commit d618879
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions shared/common-adapters/new-input.js
Expand Up @@ -21,6 +21,7 @@ export type _Props = {
containerStyle?: StylesCrossPlatform,
decoration?: React.Node,
error?: boolean,
forwardedRef: React.Ref<typeof PlainInput>,
hideBorder?: boolean,
icon?: IconType,
}
Expand All @@ -36,7 +37,7 @@ type State = {
focused: boolean,
}

class NewInput extends React.Component<DefaultProps & Props, State> {
class ReflessNewInput extends React.Component<DefaultProps & Props, State> {
static defaultProps = {
flexable: true,
keyboardType: 'default',
Expand Down Expand Up @@ -79,12 +80,19 @@ class NewInput extends React.Component<DefaultProps & Props, State> {
/>
</Box>
)}
<PlainInput {...plainInputCastProps(this.props)} onFocus={this._onFocus} onBlur={this._onBlur} />
<PlainInput
{...plainInputCastProps(this.props)}
onFocus={this._onFocus}
onBlur={this._onBlur}
ref={this.props.forwardedRef}
/>
{this.props.decoration}
</Box2>
)
}
}
// $FlowIssue doesn't know about forwardRef
const NewInput = React.forwardRef((props, ref) => <ReflessNewInput {...props} forwardedRef={ref} />)

const styles = styleSheetCreate({
container: platformStyles({
Expand Down

0 comments on commit d618879

Please sign in to comment.