npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@native-base/formik-ui

v0.1.3

Published

NativeBase Formik Integration

Downloads

709

Readme

NativeBase Formik UI

@native-base/formik-ui is the official NativeBase - Formik bindings by NativeBase Team. @native-base/formik-ui provides with form components integrated with formik hooks out of the box, Each component makes use of Formik's context, therefore you need to have Formik installed in your project, after that all you have to do is write your validationSchema, build your Form using NativeBase Formik UI components and wrap that with <Formik/> , rest will be taken care by us.

Here is an example of CheckboxControl provided by NativeBase Formik UI

import React from 'react';
import {
  CheckboxControl,
  Text,
  SubmitButton,
  ResetButton,
  Box,
  ButtonGroup,
} from '@native-base/formik-ui';
import { Formik } from 'formik';
import { Heading, Center, NativeBaseProvider } from 'native-base';
import * as Yup from 'yup';

const validationSchema = Yup.object().shape({
  tnc: Yup.boolean().equals([true], 'Terms and Condition must be checked !'),
  newsletter: Yup.boolean(),
});

function FormikCheckboxBasicExample() {
  const onSubmit = async (values) => {
    await new Promise((resolve) => setTimeout(resolve, 1000));
    console.log(values);
  };
  return (
    <Formik
      initialValues={{
        tnc: true,
        newsletter: false,
      }}
      onSubmit={onSubmit}
      validationSchema={validationSchema}
    >
      {({ values, errors }) => (
        <Box>
          <Heading>Checkbox FormControl</Heading>
          <CheckboxControl name="tnc" label="Checkbox Control Label" mt={4}>
            <Text mx={2}>Terms and Conditions</Text>
          </CheckboxControl>
          <CheckboxControl name="newsletter" mt={4}>
            <Text mx={2}>Subscribe to Our Newsletter</Text>
          </CheckboxControl>
          <Box pb={4} />
          <ButtonGroup spacing={6}>
            <SubmitButton colorScheme="teal">Next</SubmitButton>
            <ResetButton colorScheme="yellow">Reset</ResetButton>
          </ButtonGroup>
          <Box mt={4} bg="gray.100" p={3}>
            <Heading size="sm" mb={2}>
              Current State
            </Heading>
            Values: {JSON.stringify(values, null, 2)}
            Errors: {JSON.stringify(errors, null, 2)}
          </Box>
        </Box>
      )}
    </Formik>
  );
}

export default function () {
  return (
    <NativeBaseProvider>
      <Center flex={1}>
        <FormikCheckboxBasicExample />
      </Center>
    </NativeBaseProvider>
  );
}

Installation

# Using Yarn
yarn add @native-base/formik-ui

# Using NPM
npm i @native-base/formik-ui

Usage

Peer Dependency

NativeBase Formik UI has Formik, NativeBase and some various other libraries as Peer Dependencies. So make sure to have those packages installed to your project to make use of NativeBase Formik UI.

# Using Yarn
yarn add formik native-base@next react-native-svg @expo/vector-icons styled-components styled-system react-native-safe-area-context @react-native-picker/picker

# Using NPM
npm i formik native-base@next react-native-svg @expo/vector-icons styled-components styled-system react-native-safe-area-context @react-native-picker/picker

Form validations

To validate the form fields, we recommend using Yup.

# Using Yarn
yarn add yup

# Using NPM
npm i yup

Components Documentation and Examples

Contributing

See the Contribution guide to learn how to contribute to the repository and the development workflow.

License

MIT © NativeBase