Socket
Socket
Sign inDemoInstall

effector-final-form

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effector-final-form

☄️ Effector bindings for Final Form


Version published
Weekly downloads
6
decreased by-68.42%
Maintainers
1
Weekly downloads
 
Created
Source

effector-final-form

☄️ Effector bindings for Final Form 🏁

Demo

Forms values and validation rules are part of the business logic. This means that you need to be able to work with them without being bound to the UI-framework.

The goal of this project is to combine Final Form and Effector to achieve the above.

Installation

yarn add effector-final-form
# or
npm add effector-final-form
# or
pnpm add effector-final-form

Usage

Just import from the root module:

import { createForm } from 'effector-final-form';

Base example

import { createForm } from 'effector-final-form';

const form = createForm<{ login: string; password: string }>({
  onSubmit: console.log,
  subscribeOn: ['submitSucceeded', 'submitting'],
});

const loginField = form.api.registerField({
  name: 'login',
  subscribeOn: ['value', 'error', 'validating'],
  validate: (x) => (x?.length >= 3 ? undefined : 'Incorrect login'),
});

loginField.$.watch(console.log);
// {name: "login", value: null, error: null, validating: true}
// {name: "login", error: "Incorrect login", value: null, validating: false}

const passwordField = form.api.registerField({
  name: 'password',
  subscribeOn: ['value', 'error', 'validating'],
  validate: (x) => (x?.length >= 3 ? undefined : 'Incorrect password'),
});

passwordField.$.watch(console.log);
// {name: "password", value: null, error: null, validating: true}
// {name: "password", error: "Incorrect password", value: null, validating: false}

loginField.api.changeFx('John');
// {name: "login", error: null, value: "John", validating: true}
// {name: "login", error: null, value: "John", validating: false}
passwordField.api.changeFx('secret');
// {name: "password", error: null, value: "secret", validating: true}
// {name: "password", error: null, value: "secret", validating: false}
form.api.submitFx();
// {login: "John", password: "secret"}

Try it

API

Documentation link

Differences from Final Form

Documentation link

Limitations

Documentation link

More examples

Documentation link

Keywords

FAQs

Package last updated on 12 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc