
Security News
NIST Officially Stops Enriching Most CVEs as Vulnerability Volume Skyrockets
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.
@reatom/react-v2
Advanced tools
React bindings package for Reatom store.
Reatom is declarative and reactive state manager, designed for both simple and complex applications. See docs.
npm i @reatom/react-v2
or
yarn add @reatom/react-v2
@reatom/react-v2depends on and works with@reatom/core-v2andreact. You should install this packages too.
If you use React 16 or 17 you should setup batch bindings for React by yourself. Just import @reatom/react-v2/react-dom-batched-updates or @reatom/react-v2/react-native-batched-updates on the top (root) of your project to make it work before any hook call.
import '@reatom/react-v2/react-dom-batched-updates'
Connects the atom to the store represented in context and returns the state of the atom from the store (or default atom state).
const [data] = useAtom(dataAtom)
const [propAtom] = useMemo(
() => createAtom({ dataAtom }, ({ get }) => get('dataAtom')[props.id]),
[props.id],
)
const [propValue] = useAtom(propAtom)
Binds action with dispatch to the store provided in the context.
const handleUpdateData = useAction(dataAtom.update)
const handleUpdateData = useAction(
(value) => dataAtom.update({ id: props.id, value }),
[props.id],
)
If action creator don't return an action dispatch not calling.
const handleUpdateData = useAction((payload) => {
if (condition) return dataAtom.update(payload)
}, [])
This step is required only for SSR, when one node.js process may handle a few requests at the time.
// App
import React from 'react'
import { createStore } from '@reatom/core-v2'
import { reatomContext } from '@reatom/react-v2'
import { Form } from './components/Form'
import './App.css'
export const App = () => {
// create statefull reatomContext for atoms execution
const store = createStore()
return (
<div className="App">
<reatomContext.Provider value={store}>
<Form />
</reatomContext.Provider>
</div>
)
}
// components/Form
import { createPrimitiveAtom } from '@reatom/core-v2/primitives'
import { useAtom } from '@reatom/react-v2'
const nameAtom = createPrimitiveAtom('', {
onChange: (state, e) => e.currentTarget.value,
})
export const Form = () => {
const [name, { onChange }] = useAtom(nameAtom)
return (
<form>
<label htmlFor="name">Enter your name</label>
<input id="name" value={name} onChange={onChange} />
</form>
)
}
FAQs
React bindings for @reatom/core-v2
We found that @reatom/react-v2 demonstrated a not healthy version release cadence and project activity because the last version was released 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
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.