Skip to content

samchamberland/react-native-chainable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

492e29e · Apr 2, 2020

History

90 Commits
Apr 2, 2020
Mar 19, 2019
Sep 25, 2018
Apr 2, 2020
Apr 2, 2020
Apr 2, 2020
Mar 20, 2020

Repository files navigation

react-native-chainable

Chain through your React Native forms with ease

Installation

npm i react-native-chainable

Usage

class SignUpScreen extends Component {
  // ...

  render() {
    return (
      <Chainable>
        {(chain) => (
          <>
            <Chainable.Input
              value={this.state.email}
              onChangeText={(text) => this.setState({ email: text })}
              onSubmitEditing={() => chain('password')}
            />
            <Chainable.Input
              value={this.state.password}
              onChangeText={(text) => this.setState({ password: text })}
              secureTextEntry
              onSubmitEditing={() => chain('confirm')}
              name="password"
            />
            <Chainable.Input
              value={this.state.confirm}
              onChangeText={(text) => this.setState({ confirm: text })}
              secureTextEntry
              name="confirm"
              isLast
            />
          </>
        )}
      </Chainable>
    );
  }
}

API

Chainable

Render prop (function as children)

The function you pass as a child will be called with a function that allows you to chain to (i.e. set focus on) the next input by name

Type Description
(name: string) => void Function to chain to the next input by name

Chainable.Input

Props

Name Type Description
name string (optional) A name for the input
isLast boolean (optional, defaults to false) When true, the input should be considered as the last one

About

Chain through your React Native forms with ease

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published