0.4.0 • Published 4 years ago

@victorzimnikov/react-native-hooks v0.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

react-native-hooks

Hooks for React Native

useKeyboard

import { View, Button, TextInput } from "react-native";
import { useKeyboard } from "@victorzimnikov/react-native-hooks";

function KeyboardExample() {
  const keyboard = useKeyboard();

  return (
    <View>
      <Button title="Close" onPress={() => keyboard.dismiss()} />
      <TextInput />
    </View>
  );
}

useNativeRef

import { View, ScrollView, Button } from "react-native";
import { useNativeRef } from "@victorzimnikov/react-native-hooks"

function NativeRefExample() {
const scrollRef = useNativeRef<ScrollView>();

return (
  <View>
    <Button title="Scroll" onPress={() => {
      if (scrollRef.current) {
        scrollRef.current.scrollTo({ y: 200 });
      }
    }} />

    <ScrollView ref={scrollRef} />
  </View>
);
}

useStatusBar

import { useStatusBar } from "@victorzimnikov/react-native-hooks";

function StatusBarExample() {
  useStatusBar({ backgroundColor: "green", barStyle: "light-content" });

  return null;
}

useBackHandler

import { withRouter, RouteComponentProps } from "react-router";
import { useBackHandler } from "@victorzimnikov/react-native-hooks";

const BackHandlerExample = withRouter(({ history }: RouteComponentProps<object>) => {
  useBackHandler({ onBack: () => history.goBack() });

  return null;
});
0.4.0

4 years ago

0.3.1

4 years ago

0.2.1

4 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago