Installations
npm install effector-react-form
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Node Version
20.18.0
NPM Version
10.8.2
Score
63.3
Supply Chain
93.9
Quality
90.4
Maintenance
100
Vulnerability
99.6
License
Releases
Contributors
Languages
TypeScript (95.33%)
JavaScript (4.67%)
Developer
GTOsss
Download Statistics
Total Downloads
45,177
Last Day
16
Last Week
219
Last Month
1,062
Last Year
10,182
GitHub Statistics
14 Stars
336 Commits
6 Forks
2 Watching
34 Branches
7 Contributors
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
45,177
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
5
Dev Dependencies
46
Effector-react-form
Connect your forms with state manager
Visit effector-react-form.webstap to see full documentation and examples.
QuikStart
Install
1# Yarn 2yarn add effector-react-form 3 4# NPM 5npm install --save effector-react-form
Short example
Create single form1import { 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};
createForm arguments
Accepts an object with following optional params: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
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
Reason
branch protection is not maximal on development and all release branches
Details
- Info: 'allow deletion' disabled on branch 'master'
- Info: 'force pushes' disabled on branch 'master'
- Warn: 'branch protection settings apply to administrators' is disabled on branch 'master'
- Warn: could not determine whether codeowners review is allowed
- Warn: no status checks found to merge onto branch 'master'
- Warn: PRs are not required to make changes on branch 'master'; or we don't have data to detect it.If you think it might be the latter, make sure to run Scorecard with a PAT or use Repo Rules (that are always public) instead of Branch Protection settings
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/check-pull-request.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/check-pull-request.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/GTOsss/effector-react-form/check-pull-request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/check-pull-request.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/GTOsss/effector-react-form/check-pull-request.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/check-pull-request.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/GTOsss/effector-react-form/check-pull-request.yml/master?enable=pin
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 29 are checked with a SAST tool
Score
4
/10
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