Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React Js : How can i use index number to disable button ( if index = 4 then disable button )

enter image description here
i have to create a component where one person can add upto 4 addresses for doing this i have used slice(0,4) in map function but i have to make button disabled when 4 addresses are entered

How can i do this i need a solution

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

if(locations.length < 4) { <button type="button"> Add </button> }
So basically the button will appear or dissapear based on if the condition is true or false.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading