Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

effector-final-form

Package Overview
Dependencies
Maintainers
1
Versions
16
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

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by250%
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<string>({
  name: 'login',
  subscribeOn: ['value', 'error', 'validating'],
  validate: (x) => (x?.length >= 3 ? undefined : 'Incorrect login'),
});

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

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

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

loginField.api.changeFx('John');
// {name: "login", error: undefined, value: "John", validating: true}
// {name: "login", error: undefined, value: "John", validating: false}
passwordField.api.changeFx('secret');
// {name: "password", error: undefined, value: "secret", validating: true}
// {name: "password", error: undefined, 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 09 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