1

Is there a pre-built react component to edit arrays?

My Use Case: An array of members involved in a project.

Features needed:

  1. Adding users to the array
  2. Removing users from the array
  3. Keeping a minimum of 1 user in the array

1 Answer 1

2

What's up!

I don't think so, but you can do that things manually:

  1. Add Anything to the array: array.push(user) - That thing add user to the last position

  2. Removing user from the array: array.pop() - Remove the last element from array; Or array.filter(user => user.id !== id) - For example

  3. You can't exactly keep one user, but you can do something like: if(array.lenght >= 1) {...code}

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I was going to do it like this but I was just looking to see if there was a pre-built package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.