react-icons/bi#BiBookmarkMinus JavaScript Examples
The following examples show how to use
react-icons/bi#BiBookmarkMinus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CardItemWithActions.js From hackertab.dev with Apache License 2.0 | 6 votes |
export default function CardItemWithActions({ cardItem, item, index, source }) {
const { dispatcher, userBookmarks } = useContext(PreferencesContext)
const [isBookmarked, setIsBookmarked] = useState(userBookmarks.some(bm => bm.source == source && bm.url == item.url))
const onBookmarkClick = () => {
dispatcher({
type: isBookmarked ? 'unBookmarkItem' : 'bookmarkItem',
value: {
title: item.title,
url: item.url,
source
}
})
setIsBookmarked(!isBookmarked)
if (isBookmarked) {
trackUnbookmarkFrom(source)
} else {
trackBookmarkFrom(source)
}
}
useEffect(() => {
setIsBookmarked(
userBookmarks.some(bm => bm.source == source && bm.url == item.url)
)
}, [userBookmarks])
return (
<div key={`${source}-${index}`} className="blockRow">
{cardItem}
<div className={`blockActions ${isBookmarked ? "active" : ''} `}>
<button className={`blockActionButton ${isBookmarked ? "active" : ''}`} onClick={onBookmarkClick}>
{!isBookmarked ? <BiBookmarkPlus /> : <BiBookmarkMinus />}
</button>
</div>
</div>
)
}