| 1 |
import { useState } from 'react'; |
| 2 |
import { Button } from '@patternfly/react-core'; |
| 3 |
|
| 4 |
export const ButtonFavorite: React.FunctionComponent = () => { |
| 5 |
const [isFavorited, setIsFavorited] = useState(false); |
| 6 |
const toggleFavorite = () => { |
| 7 |
setIsFavorited(!isFavorited); |
| 8 |
}; |
| 9 |
return ( |
| 10 |
<Button |
| 11 |
variant="plain" |
| 12 |
aria-label={isFavorited ? 'Favorite example favorited' : 'Favorite example not favorited'} |
| 13 |
isFavorite |
| 14 |
isFavorited={isFavorited} |
| 15 |
onClick={toggleFavorite} |
| 16 |
/> |
| 17 |
); |
| 18 |
}; |