![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
recoil-spring
Advanced tools
Jumpstart Recoil - less boilerplate, more fun.
Think React Toolkit or MobX State Tree but for Recoil. Opinionated but not too much :)
no dependencies (beyond peers: React & Recoil)
Tiny !
See docs site -
The best place to find details of the Recoil:Spring API is at the doc site mentioned above. However, this section highlights the main concepts and usage.
Two ways to initialize: Object-map or chained calls.
Both code examples below are identical in their outcome:
One of Recoil's more useful yet cumbersome entities is the Atom Family. It's extremely useful for storing data over a collection. Yet, Recoil doesn't provide a way to track the items within the collection. Their docs explain that a custom atom should be employed to do that. Spring does this seamlessly when encountering a Family record.
Below is an example of the simplest read/write selector hook
import { createSelectorHook } from "recoil-spring";
import atoms from "../store";
const {
borderColor
} = atoms;
const useCollageBorderColor = createSelectorHook(borderColor);
//recoil:spring will generate a selector key using the atom's key.
//If you'd like to set your own key do the following:
const useCollageBorderColor = createSelectorHook("MyCustomBorderColorSelector", borderColor);
export default useCollageBorderColor;
import useCollageBorderColor from "./store/selectors/useCollageBorderColor";
const MyComponent = () => {
const [borderColor, setBorderColor] = useCollageBorderColor();
return (
<input
type="number"
value={borderColor}
onChange={(e) => setBorderColor(parseInt(e.target.value))}
/>
);
};
Below is an example of a computed selector, combining two atoms into one result:
import { createSelectorHook } from "recoil-spring";
import atoms from "../store";
const {
borderWidth,
borderColor,
} = atoms;
const useCollageBorder = createSelectorHook(
//need to provide a key for the selector since we use a custom getter
"CollageBorderSelector",
(get) => [get(borderColor), get(borderWidth)],
);
export default useCollageBorder;
Using the resulting readonly selector hook is done in the following way:
import useCollageBorder from "./store/selectors/useCollageBorder";
const MyComponent = () => {
const [color, width] = useCollageBorder();
return (
<div
style={{ borderColor: color, borderWidth: `${width}px` }}>
//...
</div>
);
};
Below is a selector hook that reads one (atom) value but writes to two atoms. Using it works exactly the same as any other read/write hook
import { createSelectorHook } from "recoil-spring";
import atoms from "../store";
const {
width,
height,
} = atoms;
const useDimensions = createSelectorHook(
width,
(newVal, { set }) => {
set(width, newVal);
set(height, newVal);
},
);
export default useDimensions;
logo's spring thanks to: Spring icons created by Zaenul Yahya - Flaticon
FAQs
Jumpstart Recoil - less boilerplate, more fun.
We found that recoil-spring demonstrated a not healthy version release cadence and project activity because the last version was released 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.