Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to modify onChipClick #1

Open
RockyLin opened this issue Dec 10, 2022 · 0 comments
Open

How to modify onChipClick #1

RockyLin opened this issue Dec 10, 2022 · 0 comments

Comments

@RockyLin
Copy link

I want to change the onChipClick like below. However, I don't know how to add dependency on the changed code.
Thanks a lot!

const onChipClick = (id: T) => {
let cloned = [...idsOn]
const index = idsOn.indexOf(id)
if (index > -1) {
// setIdsOn((prev) => {
// const next = [...prev]
// next.splice(index, 1)
// return next
// })
// cloned.splice(index, 1)
} else {
// setIdsOn((prev) => [...prev, id])
setIdsOn([id])

  cloned = []
  cloned.push(id)
}
return cloned

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant