Gathering detailed insights and metrics for effector-react-form
Gathering detailed insights and metrics for effector-react-form
Gathering detailed insights and metrics for effector-react-form
Gathering detailed insights and metrics for effector-react-form
npm install effector-react-form
Typescript
Module System
Node Version
NPM Version
63.3
Supply Chain
93.9
Quality
90.4
Maintenance
100
Vulnerability
99.6
License
TypeScript (95.33%)
JavaScript (4.67%)
Total Downloads
45,177
Last Day
16
Last Week
219
Last Month
1,062
Last Year
10,182
14 Stars
336 Commits
6 Forks
2 Watching
34 Branches
7 Contributors
Latest Version
3.1.5
Package Id
effector-react-form@3.1.5
Unpacked Size
305.67 kB
Size
45.40 kB
File Count
68
NPM Version
10.8.2
Node Version
20.18.0
Publised On
18 Dec 2024
Cumulative downloads
Total Downloads
Last day
-81.6%
16
Compared to previous day
Last week
-10.6%
219
Compared to previous week
Last month
70.2%
1,062
Compared to previous month
Last year
-27.9%
10,182
Compared to previous year
1
5
46
Connect your forms with state manager
1# Yarn 2yarn add effector-react-form 3 4# NPM 5npm install --save effector-react-form
1import { createForm } from 'effector-react-form'; 2 3const form = createForm<Values>({ 4 initialValues: { 5 userName: '', 6 email: '', 7 password: '', 8 repeatPassword: '', 9 }, 10 onSubmit: ({ values }) => // your post method, 11});
Set this form to our jsx
1import { useForm } from 'effector-react-form'; 2 3const validateFields = (value) => { 4 if (!value) return 'Field is required'; 5 if (value.length < 4) return 'Minimum of 4 characters'; 6 return undefined; 7}; 8 9const Form = () => { 10 const { controller, handleSubmit, submit } = useForm({ form: formSignIn }); 11 return ( 12 <form onSubmit={handleSubmit}> 13 <Input label="Name" controller={controller({ name: 'userName', validate: validateFields })} /> 14 <Input label="Name" controller={controller({ name: 'email', validate: validateFields })} /> 15 <Input label="Password" controller={controller({ name: 'password', validate: validateFields })} /> 16 <Input label="Repeat password" controller={controller({ name: 'repeatPassword', validate: validateFields })} /> 17 <button onClick={submit}> 18 submit 19 </button> 20 </form> 21 ); 22};
Custom Input component
1const Input = ({ controller, label }) => { 2 const { input,isShowError, error } = controller(); 3 4 return ( 5 <div className="input-wrap"> 6 <label>{label}</label> 7 <input {...input} value={input.value || ''} className={'input'} /> 8 {isShowError && <div className="input-error-message">{error}</div>} 9 </div> 10 ); 11};
name: form name
validate: function, for validation values of the form.
Example:
1const validateForm = ({ values }) => { 2 const errors = {}; 3 4 if (values.newPassword !== values.repeatPassword) { 5 errors.newPassword = 'passwordsDontMatch'; 6 errors.repeatPassword = 'passwordsDontMatch'; 7 } 8 9 if (values.newPassword && values.newPassword === values.oldPassword) { 10 errors.newPassword = 'passwordMustDiffer'; 11 } 12 13 return errors; 14};
mapSubmit: a function that transforms data that received from the form fields before passing it to the onSubmit function.
onSubmit: a function that fires on a form submit even.
onSubmitGuardFn: before the onSubmit function is executed, the value of this field is checked. By default, it contains a predicate function that checks if there are validation errors in form fields. If there are no errors, it returns true and onSubmit is triggered. You can pass your own predicate function that will accept the values ​​of the form fields and an object with meta.
onChange: a function that`s triggered when the form fields change. onChangeGuardFn: before the onChange function is executed, the value of this field is checked. By default, it contains a predicate function that checks if there are validation errors in form fields. If there are no errors, it will return true and onChange will be fired. You can pass your own predicate function that will accept the values of the form fields and an object with meta.
initalValues: an object with initial values of your form fields.
Example:
1const initialValues = { 2 name: "John", 3 lastName: "Smith" 4}
initialMeta: an object with initial values of your form fields.
domain: takes Effector-domain in which stores and form events will be created.
resetOuterErrorsBySubmit: takes true / false. Determines whether outer form errors should be cleared on the onSubmit event. The default is true.
resetOuterErrorByOnChange: takes true / false. Determines whether outer form errors should be cleared on the onChange event. The default is true.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
11 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 9
Reason
3 existing vulnerabilities detected
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More