Lynx.ts
GitHub
  • Overview
  • Packages
    • Core
    • Native
    • Web
  • API Reference
    • Core
    • Native
    • Web
Powered by GitBook
On this page
  • Lynx.ts Native
  • Requirements
  • Install
  • Usage
  • API Reference
  • Something's missing?
  • Contributions
  • License

Was this helpful?

Edit on GitHub
  1. Packages

Native

PreviousCoreNextWeb

Last updated 1 year ago

Was this helpful?

Lynx.ts Native

TypeScript-first, lightning fast Forms for React.js and React Native. The @lynxts/native package provides abstractions and helpers specifically for React Native, which makes working with forms simpler, more maintainable, and intuitive.

Requirements

  • : Same as the @lynxts/native version used

  • : >=16.8.0

  • : >=0.59.0

Install

Using Yarn:

yarn add @lynxts/core @lynxts/native

Using NPM:

npm i @lynxts/core @lynxts/native

Usage

To make using forms in React Native as simple as possible, @lynxts/native provides submit-like components based on every "touchable" core component (Button, TouchableHighlight, TouchableOIpacity, etc.). These components are just abstractions where the useFormSelector(..) hook is used to access the submit() function form the context to be called in the onPress(..) event.

import { FormProvider } from "@lynxts/core";
import { SubmitButton, textFieldOf } from "@lynxts/native";
import { ReactElement, memo, useCallback } from "react";
import { ObjectSchema, object, string } from "yup";

interface Login {
  email: string;
  password: string;
}

const schema: ObjectSchema<Login> = object({
  email: string().email().required(),
  password: string().required(),
});

const TextField = textFieldOf<Login>();

const SignIn = memo((): ReactElement => {

  const handleSubmit = useCallback((values: Login): void => {
    const { email, password } = values;
    // Use the validated value to sign in!
  }, []);

  return (
    <FormProvider onSubmit={handleSubmit} validation={schema}>
      <TextField name="email" label="Email:" />
      <TextField name="password" label="Password:" />

      <SubmitButton title="Sign In" />
    </FormProvider>
  );
});

API Reference

Something's missing?

Contributions

Contributions are very welcome! To do so, please fork this repository and open a Pull Request to the main branch.

License

It also provides a helper TextField<T> component based on the foundational component. This component adds a label and error handling and its intention is for users to quickly jump into using simple forms. However, we strongly recommend creating you own abstractions to get better control and customization.

You can find the complete API refence 📚

Suggestions are always welcome! Please create an describing the request, feature, or bug. We'll try to look into it as soon as possible 🙂

here
issue
MIT License
lynxts/core
React.js
React Native
TextInput
CI
Release
Known Vulnerabilities
Lynx.ts Logo
NPM license
custom field
GitHub Release Date
NPM version
NPM downloads
NPM bundle size