Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ethercreative/react-native-form-auto-next

A simple React Native form component that automatically focuses the next TextInput on return
https://github.com/ethercreative/react-native-form-auto-next

Last synced: about 2 months ago
JSON representation

A simple React Native form component that automatically focuses the next TextInput on return

Awesome Lists containing this project

README

        

# react-native-form-auto-next

A simple React Native form component that automatically focuses the next TextInput on return

## Installation

```
npm install react-native-form-auto-next
yarn add react-native-form-auto-next
expo install react-native-form-auto-next
```

## Usage

```js
import React from 'react';
import { View } from 'react-native';
import { Form } from 'react-native-form-auto-next';

export default () => {
const submit = () => {
// Submit the form
};

return (



// Nesting works


// Override behaviour with onSubmitEditing prop


);
};
```

## Usage with custom/abstracted inputs

```js
// Form.js
import React from 'react';
import { View } from 'react-native';
import { Form } from 'react-native-form-auto-next';
import CustomInput from './CustomInput';

export default () => {
const submit = () => {
// Submit the form
};

return (



// Nesting works


// Override behaviour with onSubmitEditing prop


);
};

// CustomInput.js
import React, { Component } from 'react';
import { TextInput } from 'react-native';

class CustomInput extends Component {
constructor(props) {
super(props);
this.input = null;
}

componentDidMount() {
const { onRef } = this.props;

if (!onRef) {
return;
}

onRef(this);
}

focus = () => {
if (!this.input) {
return;
}

this.input.focus();
};

render() {
return (this.input = input)} />;
}
}
```