Advertisement
markymarkmutai

Button active on array category

Apr 30th, 2022
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const [isActive, setActive] = useState(false)
  2.  
  3. const btnSelect = () => {
  4. setActive(!isActive);
  5. }
  6.  
  7. return (
  8. <div className='flex flex-col'>
  9. {
  10. button.map((cat, i) => {
  11. return (
  12.  
  13. <button
  14. type="button"
  15. onClick={() => {
  16. filter(cat);
  17. btnSelect();
  18. }}
  19. className={`title w-32 h-16 my-2 ${isActive ? 'bg-sky-500' : 'bg-red-400'}`}
  20. >
  21. {cat}
  22. </button>
  23.  
  24. )
  25. })
  26. }
  27. </div >
  28. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement