Skip to content

Commit 7b7e1be

Browse files
authored
docs(withNextInputAutoFocus): update readme (#104)
1 parent f4885cd commit 7b7e1be

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ Authorized types as of now are `email`, `password`, `digits` and `name`. Setting
382382

383383
Check [the props set by the type](./src/withInputTypeProps) in the source!
384384

385-
### withNextInputAutoFocus
385+
### withNextInputAutoFocus [See example in Snack](https://snack.expo.io/@almouro/Z3JlYX)
386386

387387
- when an input is submitted, it will automatically focuses on the next or submit the form if it's the last one
388388
- sets return key to "next" or "done" if input is the last one or not
@@ -396,7 +396,18 @@ import {
396396
withNextInputAutoFocusInput
397397
} from "react-native-formik";
398398

399-
const MyInput = withNextInputAutoFocusInput(TextInput);
399+
class CustomInput extends React.PureComponent {
400+
// Implement a focus function that focused whatever needs to be focused
401+
focus = () => { this.input.focus(); }
402+
403+
render() {
404+
return (
405+
<TextField ref={input => this.input = input} {...this.props} />
406+
);
407+
}
408+
}
409+
410+
const MyInput = withNextInputAutoFocusInput(CustomInput);
400411
const Form = withNextInputAutoFocusForm(View);
401412

402413
export default props => (

0 commit comments

Comments
 (0)