Skip to content

metehankurucu/rn-use-input-focus

Repository files navigation



rn-use-input-focus


npm package downloads license

A React Native hook that makes it easier to use focus in inputs without create a lot of refs


npm i rn-use-input-focus

Usage

import useInputFocus from "rn-use-input-focus";

const App = () => {
  const [inputRefs, focus] = useInputFocus(["email", "password"]);

  return (
    <View>
      <TextInput onSubmitEditing={() => focus("email")} placeholder="Name" />
      <TextInput
        ref={inputRefs.email}
        onSubmitEditing={() => focus("password")}
        placeholder="Email"
      />
      <TextInput ref={inputRefs.password} placeholder="Password" />
    </View>
  );
};

Full example

Releases

No releases published

Packages

No packages published