We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
There is a JS data structure called a set which is quite cool (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set), it behaves a lot like an object but can be used more like arrays.
set
for example in useAddWorkSpace you have the following code
useAddWorkSpace
const handleAmenityChange = (amenity: string) => { if (selectedAmenities.includes(amenity)) { setSelectedAmenities(selectedAmenities.filter((a) => a !== amenity)); } else { setSelectedAmenities([...selectedAmenities, amenity]); } };
using a set, you could rewrite this
const handleAmenityChange = (amenity: string) => { const amenitiesSet = new Set(selectedAmenities); if (amenitiesSet.has(amenity)) { amenitiesSet.delete(amenity); } else { amenitiesSet.add(amenity); } setSelectedAmenities([...amenitiesSet]); };
I probably wouldn't bother! but they're handy for deduplicating arrays and quickly adding / removing like this
The text was updated successfully, but these errors were encountered:
No branches or pull requests
There is a JS data structure called a
set
which is quite cool (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set), it behaves a lot like an object but can be used more like arrays.for example in
useAddWorkSpace
you have the following codeusing a set, you could rewrite this
I probably wouldn't bother! but they're handy for deduplicating arrays and quickly adding / removing like this
The text was updated successfully, but these errors were encountered: