@material-ui/icons APIs
- ExpandMore
- Delete
- Close
- Visibility
- VisibilityOff
- Check
- Add
- Edit
- Search
- ExpandLess
- Settings
- Person
- Info
- Clear
- ExitToApp
- ArrowDropDown
- Home
- GitHub
- Warning
- ArrowBack
- SearchOutlined
- Done
- LocationOn
- PlayArrow
- Apps
- Brightness4
- Brightness7
- Description
- KeyboardArrowDown
- KeyboardArrowLeft
- KeyboardArrowRight
- MoreVert
- LocationCity
- Map
- Image
- AccountCircle
- InfoOutlined
- Create
- Block
- Replay
- AddCircle
- HomeRounded
- GetApp
- ChevronLeft
- ChevronRight
- CloudDownload
- CheckCircleOutline
- Send
- LockOpen
- Cancel
- NavigateNext
- AccountBox
- DragIndicator
- FavoriteBorderOutlined
- AccessTime
- DoneAll
- CheckCircle
- CropFree
- LockOutlined
- Undo
- Dashboard
- People
- PhotoLibrary
- HomeOutlined
- Group
- ArrowDropUp
- Remove
- ArrowUpward
- Save
- ArrowForward
- AttachFile
- Headset
- SignalCellularAlt
- ArrowForwardIos
- PlayCircleFilled
- AccessAlarm
- Adjust
- BarChart
- CloseRounded
- PlayArrowOutlined
- ImageRounded
- MenuBookRounded
- RefreshRounded
- HourglassEmptyOutlined
- Announcement
- Ballot
- QuestionAnswerOutlined
- CloudUpload
- SkipNext
- ArrowRightAlt
- MoreHoriz
- FileCopy
- MenuBook
- Language
- AlternateEmail
- FolderOpen
- Lock
- Pets
- AddCircleRounded
- ExploreRounded
- WbSunnyRounded
- Brightness2Rounded
- DonutLargeRounded
- AssistantRounded
- AccountCircleRounded
- ExitToAppRounded
- VpnKey
- MailOutline
- Smartphone
- DeleteForever
- LanguageOutlined
- Colorize
- SignalCellularConnectedNoInternet2Bar
- SignalCellularConnectedNoInternet0Bar
- SignalCellular4Bar
- DeleteOutline
- NewReleases
- LocalOffer
- Assessment
- Place
- TrendingDown
- ShoppingCart
- Stop
- RotateLeft
- Menu
- Flag
- Forum
- GroupSharp
- InsertEmoticon
- NotificationsActive
- PhoneIphone
- AllInbox
- Comment
- Photo
- PlaylistAddCheck
- CloudUploadRounded
- ExpandMoreOutlined
- History
- PersonOutlineOutlined
- ArrowForwardIosRounded
- ArrowBackIosRounded
- AssignmentOutlined
- VerticalAlignCenterOutlined
- CalendarTodayOutlined
- Error
- PlaylistPlay
- MusicNoteTwoTone
- Portrait
- ExploreOutlined
- DeleteRounded
- EditRounded
- SaveRounded
- CreateNewFolder
- MeetingRoom
- MenuOpenRounded
- MenuRounded
- DateRange
- CallEnd
- Assignment
- KeyboardBackspace
- BluetoothSearching
- CameraAlt
- PlaylistAdd
- Favorite
- Bluetooth
- OpenInBrowser
- Loop
- FileCopyOutlined
- NavigateBefore
- MergeType
- Dvr
- PersonOutline
- PlayCircleFilledWhiteOutlined
- StoreMallDirectoryOutlined
- SupervisedUserCircleOutlined
- MonetizationOn
- OpenInNew
- ArrowDownward
- AddBox
- FilterList
- FirstPage
- LastPage
- ViewColumn
- Notifications
- DriveEta
- LocalTaxi
- Redo
- AccountTree
- TextFields
- SaveAlt
- ThumbDown
- ThumbUp
- LocalPhone
- VolumeUp
- VolumeDown
- Translate
- AddCircleOutlined
- RemoveCircleOutlined
- Router
- RemoveRedEye
- Chat
- Mood
- Mic
OtherRelated APIs
@material-ui/icons#ThumbDown JavaScript Examples
The following examples show how to use
@material-ui/icons#ThumbDown.
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: LikeDislikes.js From youtube-clone with MIT License | 4 votes |
LikeDislikes = ({ size, showDislikes = true, type, id, videoId }) => {
const options = [-1, 1]; //Dislike, Like
const [rating, setRating] = useState(null);
const [dislikes, setDislikes] = useState(0);
const [likes, setLikes] = useState(0);
const isAuth = useSelector(({ channel }) => channel.isAuth);
const classes = useStyles();
useEffect(() => {
const fetchRating = async () => {
const url1 = `/api/ratings/${type}/${videoId}/${id}`;
const url2 = `/api/ratings/user/${type}/${videoId}/${id}`;
try {
const {
data: { ratings },
} = await api.get(url1);
const { data } = await api.get(url2);
setLikes(ratings.likes);
setDislikes(ratings.dislikes);
if (data) {
setRating(data.rating);
}
} catch (err) {
console.log(err);
}
};
fetchRating();
}, [type, id]);
const getRating = (option) => options[option];
const handleThumbClick = async (newRating) => {
if (isAuth) {
const url = `/api/ratings/${type}/${videoId}/${id}`;
try {
if (!rating) {
await api.post(url, {
rating: newRating,
});
if (newRating > 0) {
setLikes((count) => ++count);
} else {
setDislikes((count) => ++count);
}
setRating(newRating);
} else if (rating && newRating !== rating) {
await api.patch(url, {
rating: newRating,
});
if (rating > 0) {
setDislikes((count) => ++count);
setLikes((count) => --count);
} else {
setDislikes((count) => --count);
setLikes((count) => ++count);
}
setRating(newRating);
} else {
console.log("need to delete");
await api.delete(url);
if (rating > 0) {
setLikes((count) => --count);
} else {
setDislikes((count) => --count);
}
setRating(null);
}
} catch (err) {
console.log(err);
}
} else {
window.location.assign(urlJoin(BACKEND_URL, "/api/auth/google"));
}
};
return (
<div className={classes.root}>
<div className={classes.rating}>
<ThumbUp
onClick={() => handleThumbClick(getRating(1))}
className={clsx(classes.thumbBtn, {
[classes.small]: size === "small",
[classes.active]: getRating(1) === rating,
})}
/>
<Typography variant="body2">
{new NumAbbr().abbreviate(likes, 2)}
</Typography>
</div>
<div className={classes.rating}>
<ThumbDown
onClick={() => handleThumbClick(getRating(0))}
className={clsx(classes.thumbBtn, {
[classes.small]: size === "small",
[classes.active]: getRating(0) === rating,
})}
/>
{showDislikes && new NumAbbr().abbreviate(dislikes, 2)}
</div>
</div>
);
}