
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-dynamic-form-v2
Advanced tools
React library for dynamic form generation using MUI components and Formik
react-dynamic-form-v2 is a React library for dynamically generating forms using JSON configurations. It leverages Material-UI (MUI) components and Formik for form handling and validation.
You can install the library via npm:
npm install react-dynamic-form-v2
Here's a basic example of how to use the react-dynamic-form-v2 library:
import React from 'react';
import { DynamicForm } from 'react-dynamic-form-v2';
const formJson = {
"form_data":[
{
"key":"name",
"type":"input",
"props":{
"placeholder":"Enter name",
"pattern":"^[a-z A-Z 0-9\\s]{1,50}$",
"type":"text",
"required":true,
"label":"Name",
"minLength":1,
"maxLength":50
}
},
{
"key":"address",
"type":"select",
"defaultValue":"",
"props":{
"label":"Location",
"options":[
{
"value":"40acb6ff-3f2f-4b95-9ef9-c15c8d050bbe",
"label":"New Delhi"
}
]
}
},
{
"key":"telephone",
"type":"tel",
"defaultValue":"",
"props":{
"placeholder":"Enter mobile number",
"label":"Mobile"
}
},
{
"key":"states",
"type":"autocomplete",
"props":{
"label":"States",
"placeholder":"Type to search",
"required":true,
"options":[
"Alabama",
"Alaska",
"American Samoa",
"Arizona",
"Arkansas",
"California",
"Colorado",
"Connecticut",
"Delaware"
]
}
},
{
"key":"description",
"type":"textarea",
"templateOptions":{
"label":"Description",
"placeholder":"Enter your comments",
"required":true,
"rows":4,
"cols":50
}
},
{
"key":"dob",
"type":"date",
"templateOptions":{
"label":"Date of Birth",
"placeholder":"Select your date of birth",
"required":true,
"minDate":"1900-01-01",
"maxDate":"2023-12-31"
}
},
{
"key":"gender",
"type":"radio",
"templateOptions":{
"label":"Gender",
"required":true,
"options":[
{
"label":"Male",
"value":"male"
},
{
"label":"Female",
"value":"female"
},
]
}
},
{
"key":"agreeTerms",
"type":"checkbox",
"templateOptions":{
"label":"I agree to the terms and conditions",
"required":true
}
}
]
};
export default function App() {
const onSubmit = (data) => {
console.log("Form data: ", data);
};
const breakpoints = {
xs: 12,
md: 6,
lg: 6
};
return (
<div className="App">
<h1>Hello Dynamic Form</h1>
<DynamicForm
formJson={formJson}
buttonClick={onSubmit}
breakpoints={breakpoints}
formValues={apiData}
>
<button type='submit'>Submit</button>
</DynamicForm>
</div>
);
}
To pre-populate form fields with data from an API, you can pass an formValues prop to the DynamicForm component. The keys in the formValues object should match the key values in the formJson to ensure correct field mapping.
formValues:const apiData = {
legal_name: "Your name",
address: "test",
telephone: "+9190******23",
states: "Alaska",
description: "Test description",
dob: "1990-01-01",
gender: "male",
};
breakpoints The breakpoints prop allows you to control how each field is displayed on different screen sizes (xs, md, lg, xl).
The formJson object structure is as follows:
Each field object in the form_data array should contain:
For certain types like radio, checkbox, textarea, and date, the templateOptions are used:
radio and checkbox) Array of options, each with a label and value.textarea) Number of rows for the textarea.textarea) Number of columns for the textarea.date) The minimum allowed date.date) The maximum allowed date.Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
formValues Prop: The formValues object is added as a prop to DynamicForm to pre-populate the form fields. This is reflected in the example usage and explained in the documentation.formJson and how it can be used to define form fields dynamically.breakpoints prop works to make the form responsive.Let me know if you want further adjustments!
FAQs
React library for dynamic form generation using MUI components and Formik
We found that react-dynamic-form-v2 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.