Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@shopify/react-form-state
Advanced tools
@shopify/react-form-state
Manage React forms tersely and type-safely with no magic.
This library is now superseded by @shopify/react-form as it allows you to write the preferred, functional, and hooks-driven React components over class-based ones.
$ yarn add @shopify/react-form-state
<FormState />
The default component exported by this library is <FormState />
.
import FormState from '@shopify/react-form-state';
// Fields here refers to the inferred type of your initialValues object
interface Props<Fields> {
initialValues: Fields;
validators?: Partial<ValidatorDictionary<Fields>>;
onSubmit?: SubmitHandler<Fields>;
validateOnSubmit?: boolean;
children(form: FormDetails<Fields>): React.ReactNode;
}
Its only mandatory props are initialValues
and children
. The initialValues
prop is used to infer all the types for the rest of the component, and to generate handlers and field state objects. The children
prop expects a function of the current state of the form, which is represented by a FormDetails
object.
<FormState initialValues={myInitialValues}>
{({fields, dirty, valid, submitting, errors, reset, submit}) => {
return /* some cool ui */;
}}
</FormState>
For detailed explanations of how to use <FormState />
check out the guide.
validators
The library also makes a number of validation factory functions available out of the box that should help with common use cases, as well as some tools to make building reusable custom validators easy.
import {validate, validators} from '@shopify/react-form-state';
For detailed explanations of the validation utilities, check out the validation docs.
FAQs
Manage React forms tersely and type-safely with no magic
The npm package @shopify/react-form-state receives a total of 817 weekly downloads. As such, @shopify/react-form-state popularity was classified as not popular.
We found that @shopify/react-form-state demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.