remix-validated-form
Version:
Form component and utils for easy form validation in remix
19 lines (18 loc) • 519 B
JavaScript
/**
* This is basically what `atomFamily` from jotai does,
* but it doesn't make sense to include the entire jotai library just for that api.
*/
export const storeFamily = (create) => {
const stores = new Map();
const family = (formId) => {
if (stores.has(formId))
return stores.get(formId);
const store = create(formId);
stores.set(formId, store);
return store;
};
family.remove = (formId) => {
stores.delete(formId);
};
return family;
};