1.0.8 • Published 4 years ago

react-native-template-agile-rn v1.0.8

Weekly downloads
12
License
MIT
Repository
-
Last release
4 years ago

Overview

Key features

  • React Hooks 🎣
  • Easy form validation
  • Fast layout mounting 📱

Guides

<Form /> element

API

PropTypeRequiredNote
schemaYup.objectfalseValidates form fields on button press
initialDataObjectfalseDefines initial values in form fields
onSubmitFunctiontrueWill be called after button press, if data passes schema validation
refReact.createReftrueMust be defined to send data on form button press ref.current.send()

Example

import React, { useRef } from 'react';
import { Button } from 'react-native';
import * as yup from 'yup';

import { Form, Input } from '~/components';

const schema = yup.object().shape({
  email: yup
    .string()
    .email()
    .required(),
  password: yup.string().required(),
});

export default function Auth() {
  const formRef = useRef();

  function handleSubmit(data) {
    console.log(data);

    /*
       {
        email: 'example@mail.com',
        password: '123'
       }
    */
  }

  return (
    <Form schema={schema} onSubmit={handleSubmit} ref={formRef}>
      <Input name="email" label="Email" />
      <Input name="password" label="Password" />

      <Button title="Enter" onPress={() => formRef.current.send()} />
    </Form>
  );
}

<Block /> element

API

PropTypeDefaultNote
containerBooleanfalseAdds a SafeAreaView + KeyboardAvoidingView around component
weightBoolean/Number"none"Defines the weight of component (flex)
colorString"transparent"Defines the component color
alignBoolean/String"flex-start"Sets align-items style to the component
justifyBoolean/String"flex-start"Sets justify-content style to the component
rowBooleanfalseSets flex-direction row to the component
distanteArray<Number>[]Sets padding into the component

Example

import React from 'react';
import { Text } from 'react-native';

import { Block } from '~/components';

export default function App() {
  return (
    <Block container align justify>
      <Text>Hello World</Text>
    </Block>
  );
}

Dependencies

  • Async Storage
  • Prop Types
  • React Native Gesture Handler
  • React Native Masked Text
  • React Native Vectors Icons
  • React Navigation
  • Redux
  • Redux Saga
  • Styled Components
  • Yup

Dev Dependencies

  • Eslint
  • Prettier
  • Reactotron