react-id-generator | Simple and universal HTML-id generator for React | Frontend Framework library
kandi X-RAY | react-id-generator Summary
kandi X-RAY | react-id-generator Summary
Simple and universal HTML-id generator for React.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-id-generator
react-id-generator Key Features
react-id-generator Examples and Code Snippets
Community Discussions
Trending Discussions on react-id-generator
QUESTION
So in React
I made a button that every time you click it it generates a new button with a unique id using react-id-generator
.
Now I want to get the id from the last button in the list and every time I click a remove button it should remove the last button generated.
Here is what have I done so far and i tried to remove the last button but it removes all the buttons:
...ANSWER
Answered 2020-Apr-29 at 09:32You can try this:
QUESTION
So I am trying to gen a div with a button onClick of a button but I get an error that is stopping me from doing this.
Error: TypeError: this.state.addroom.map is not a function
But I saw that when I click my button once it doesn't show the error but it doesn't generate the div with the button either.
Here is my code:
...ANSWER
Answered 2020-Apr-29 at 06:57There are a few things off with your code.
First of all the addroom
in your state is a string array in your constructor, but in the handleClick
method you set it like this.setState({ addroom: htmlId })
which will set it to a string
and on a string
type the map
function is not defined, hence the error.
You should add an item to the array like this.setState({ addroom: [...this.state.addroom, htmlId] })
Secondly, in your handleClick
you shouldn't return jsx, if you wan to render data for your addroom
array, you should do it in the render
method, and in the handleClick
you should just modify the addroom
state variable.
You can achieve this like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-id-generator
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page