
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
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.
react-dynamic-input
Advanced tools
An input that can be replicated with a button, each input has its own state
react-dynamic-input allows you to create multiple inputs that each have their own unique state that you define. It also comes with a built in onSubmit button which takes a function that you ceate. Add it to a form or whatever user input you need!
npm i react-dynamic-input
Add DynamicInput to your components like this:
import DynamicInput from "react-dynamic-input"
class YourComponent extends React.Component {
render() {
return <DynamicInput />
}
}
props for the <DynamicInput/>:
| Name | Required | Default | Type | Description |
|---|---|---|---|---|
inputName | yes | string | The key you would like to be assigned to the state of each of the inputs that are created [{ [inputName]: ""}] | |
addButtonText | no | "Add Input" | string | The text you would like to appear on the button to create another input |
setInput | yes | Function | The setState function you would like to be executed when a user types into the input (setState, or useState) | |
input | yes | [] | Array | The state you will pass to the component. Must be the shape of [{ [inputName]: ""}] |
onSubmit | no | Function | The onSubmit function you would like to execute when a user submits the form. If nothing is provided there will be no button and you can add your own. | |
submitButtonText | no | "Submit" | string | The text you would like to appear on the submit button |
addPosition | no | "top" | string | The position you would like the "Add Input" button to be. "top" will make it above the inputs, "bottom" will place it below and next to the submit button |
type | no | "text" | string | The type of input you would like to use |
removeText | no | "Remove" | string | The text you would like to have in the remove input button |
placeholderNumbered | no | false | boolean | If you would like the placeholder text to have a number after the text, set this to true |
toolTip | no | false | boolean | You can have a tooltip pop up when you scroll your mouse over the add button |
toolTipText | no | string | The text you would like to appear in the tooltip above the add button | |
label | no | "" | string | If you would like a label for the inputs you can put the text here (will appear as an <h4></h4 element above the inputs) |
import React, { useState } from "react"
import DynamicInput from "react-dynamic-input"
const App = () => {
const [input, setInput] = useState([{ name: "" }])
const showState = () => {
alert(input.map(item => item.name))
}
return (
<div>
<DynamicInput
inputName="name"
addButtonText="Add Another Input"
setInput={setInput}
input={input}
onSubmit={showState}
submitButtonText="Submit"
addPosition="bottom"
type="text"
placeholderNumbered={true}
toolTip={true}
toolTipText="Add another input"
label="My Input"
/>
{input.map((item, index) => (
<p key={(index + 1) * 2}>{item.name}</p>
))}
</div>
)
}
export default App
Each of the Elements in the react-dynamic-input Component can be targeted througn CSS with a className attribute (the entire component can be targeted with an id):
#DynamicInput {
/* Add whatever CSS you'd like! */
}
.addButton {
/* Add whatever CSS you'd like! */
}
.removeButton {
/* Add whatever CSS you'd like! */
}
.submitButton {
/* Add whatever CSS you'd like! */
}
.dynamicInput {
/* Add whatever CSS you'd like! */
}
.dynamicLabel {
/* Add whatever CSS you'd like! */
}
.dynamicTooltip {
/* Add whatever CSS you'd like! */
}
.dynamicTooltipText {
/* Add whatever CSS you'd like! */
}
I am open to ideas and improvments! If you have a feature or bug fix open a PR or submit an issue! Thank you! 🛰
FAQs
An input that can be replicated with a button, each input has its own state
The npm package react-dynamic-input receives a total of 2 weekly downloads. As such, react-dynamic-input popularity was classified as not popular.
We found that react-dynamic-input 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
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.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.