![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
commodo-fields-object
Advanced tools
A simple object field, used with the Commodo "withFields" higher order function.
A simple object field, used with the Commodo withFields
higher order function.
npm install --save commodo-fields-object
Or if you prefer yarn:
yarn add commodo-fields-object
import { compose } from "ramda";
import { withFields, string } from "@commodo/fields";
import { object } from "commodo-fields-object";
const Page = compose(
withFields({
title: string(),
content: object(), // Use it to store a single object.
previousContent: object({ list: true }) // Or use it to store a list of objects.
// Other fields you might need...
}),
// Other higher order functions (HOFs) you might need...
)();
const page = new Page();
company.name = "Welcome!";
// The object field can only accepts objects (with any structure).
company.content = {
elements: [
{
type: "xyz",
text: "Lorem ipsum ...",
elements: [{ type: "image", src: "https://..." }]
}
]
};
company.previousContent = [
{ elements: [ ... ] },
{ elements: [ ... ] },
{ elements: [ ... ] }
];
// The following will throw the WithFieldsError error.
company.content = "A string...";
company.previousContent = [
{ elements: [ ... ] },
"A string...",
{ elements: [ ... ] }
];
Note: alternatively, you could've also used the populate
method to assign the data:
const company = new Company();
company.populate = {
name: "Welcome!",
content: {
elements: [
{
type: "xyz",
text: "Lorem ipsum ...",
elements: [{ type: "image", src: "https://..." }]
}
]
},
previousContent: [
{ elements: [ ... ] },
{ elements: [ ... ] },
{ elements: [ ... ] }
]
};
This field can be used when you don't have a fixed structure of the data that's going to be assigned to it. The above example shows a perfect situation where this is necessary. Note that, although the field does allow any size of the object to be assigned, it's up to you to establish proper data validation and keep your code safe.
And finally, have in mind that, if it turns out that the data that's going to be assigned to the field, actually has a fixed structure, it's always best to use the fields
field.
Thanks goes to these wonderful people (emoji key):
Adrian Smijulj 💻 📖 💡 👀 ⚠️ |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
A simple object field, used with the Commodo "withFields" higher order function.
The npm package commodo-fields-object receives a total of 424 weekly downloads. As such, commodo-fields-object popularity was classified as not popular.
We found that commodo-fields-object 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
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.