
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@flowerforce/flower-react-form
Advanced tools
Flower React Form is a form management library for React. Built on top of Flower Core, it can be easily integrated with FlowerReact or used independently while preserving Flower’s key features, such as render optimization, automatic data handling, and validation rule management.
For more info flowerjs.it/
Flower React Form can be installed via npm or yarn for use in any JavaScript project.
#NPM
npm install @flowerforce/flower-react-form
#YARN
yarn add @flowerforce/flower-react-form
Flower React Form works with redux global state.
If you starts an application with Flower React Form from scratch, you need to wrap your application with FormProvider The FormProvider component wraps the entire application, providing a global context for managing the application flow.
import React from 'react'
import { FormProvider } from '@flowerforce/flower-react-form'
function Root() {
return (
<FormProvider>
<App />
</FormProvider>
)
}
If your application is already built with redux as global state manager, you can use differents approaches:
In this case, you need to wrap your application with the FormProvider component in addition to the classic Redux provider. The order of providers is not relevant, since their redux contexts are different.
import React from 'react'
import { Provider } from 'react-redux'
import { yourStore } from 'yourStore'
import { FormProvider } from '@flowerforce/flower-react-form'
function Root() {
return (
<Provider store={yourStore}>
<FormProvider>
<App />
</FormProvider>
</Provider>
)
}
For this scenario, we provides createStoreWithFlowerData
This functions takes a configureStoreOptions
object (same as createStore from redux) and an optional middlewaresBlacklist
, since flower inject automatically some middlewares in its store.
To generate slices fully compatible, you can use createSliceWithFlowerData, a function same as createSlice
from redux.
Let's see the needed configuration
import React from 'react'
import { Provider } from 'react-redux'
import { FormProvider, createStoreWithFlowerData, createSliceWithFlowerData } from '@flowerforce/flower-react-form'
const myStoreWithFlower = createSliceWithFlowerData({
name: 'myStore',
initialData: {},
reducers: {
add: (state) => {
state.count += 1
}
}
})
const storeWithFlower = createStoreWithFlowerData({
reducer: {
myStore: myStoreWithFlower.reducer,
}
})
function Root() {
return (
<Provider store={storeWithFlower}>
<App />
</Provider>
)
}
In this scenario, we need a single provider, so we use the default redux provider
The FlowerForm component defines a form with a specific name, which serves as a unique identifier for the form. It is the main component for defining forms, accepting a required "name" property and an initialState field for prepopulating values.
import React from 'react'
import { FlowerForm, FlowerField } from '@flowerforce/flower-react-form'
export const Page = () => {
<FlowerForm
name="form-test"
initialState={{ name: 'andrea', surname: 'rossi' }}
>
<FlowerField
id="name"
validate={[
{
message: 'is equal',
rules: { $and: [{ name: { $eq: 'andrea' } }] }
}
]}
>
your input component...
</FlowerField>
<FlowerField
id="surname"
validate={[
{
message: 'is equal',
rules: { $and: [{ surname: { $eq: 'rossi' } }] }
}
]}
>
your input component...
</FlowerField>
</FlowerForm>
}
Edit on [codesandbox/](add link)
Here, we are using the useFlower hook to obtain some essential functions for navigation and handling of the application flow.
import React from 'react'
import { FlowerForm, FlowerField } from '@flowerforce/flower-react-form'
const ViewFormState = () => {
const { isValid, getData, setData, ...rest } = useFlowerForm()
return <span>{isValid}</span>
}
export const Page = () => {
<FlowerForm
name="form-test"
initialState={{ name: 'andrea', surname: 'rossi' }}
>
<FlowerField
id="name"
validate={[
{
message: 'is equal',
rules: { $and: [{ name: { $eq: 'andrea' } }] }
}
]}
>
your input component...
</FlowerField>
<FlowerField
id="surname"
validate={[
{
message: 'is equal',
rules: { $and: [{ surname: { $eq: 'rossi' } }] }
}
]}
>
your input component...
</FlowerField>
<ViewFormState />
</FlowerForm>
}
Edit on [codesandbox/](add link)
import React from 'react'
import { FlowerForm, FlowerField } from '@flowerforce/flower-react-form'
export const Page = () => {
const { isValid, getData, setData, ...rest } = useFlowerForm('form-test')
return (
<FlowerForm
name="form-test"
initialState={{ name: 'andrea', surname: 'rossi' }}
>
<FlowerField
id="name"
validate={[
{
message: 'is equal',
rules: { $and: [{ name: { $eq: 'andrea' } }] }
}
]}
>
your input component...
</FlowerField>
<FlowerField
id="surname"
validate={[
{
message: 'is equal',
rules: { $and: [{ surname: { $eq: 'rossi' } }] }
}
]}
>
your input component...
</FlowerField>
<ViewFormState />
</FlowerForm>
)
}
Edit on [codesandbox/](add link)
The Flower React docs are published at flowerjs.it/
FAQs
FlowerJS utils for Form handling.
We found that @flowerforce/flower-react-form demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.