Like button with react
How do I make an like button with react?
What is a like button with react? How do you make a like button with react? This script and codes were developed by Mohammed Fawzy on 26 January 2023, Thursday.
Like button with react - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>like button with react</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="app"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Like button with react - Script Codes CSS Codes
.like-social { margin-bottom: 20px; text-align: center;
}
.like-social .open_video_likes { margin: 40px;
}
.like-social .myButton { -moz-box-shadow: 3px 4px 0px 0px #8a2a21; -webkit-box-shadow: 3px 4px 0px 0px #8a2a21; box-shadow: 3px 4px 0px 0px #8a2a21; background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #c62d1f), color-stop(1, #f24437)); background: -moz-linear-gradient(top, #c62d1f 5%, #f24437 100%); background: -webkit-linear-gradient(top, #c62d1f 5%, #f24437 100%); background: -o-linear-gradient(top, #c62d1f 5%, #f24437 100%); background: -ms-linear-gradient(top, #c62d1f 5%, #f24437 100%); background: linear-gradient(to bottom, #c62d1f 5%, #f24437 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c62d1f', endColorstr='#f24437',GradientType=0); background-color: #c62d1f; -moz-border-radius: 18px; -webkit-border-radius: 18px; border-radius: 18px; border: 1px solid #d02718; display: inline-block; cursor: pointer; color: #ffffff; font-family: Arial; font-size: 17px; padding: 7px 25px; text-decoration: none; text-shadow: 0px 1px 0px #810e05; outline: none; width: 100px;
}
.like-social .myButton:hover { background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f24437), color-stop(1, #c62d1f)); background: -moz-linear-gradient(top, #f24437 5%, #c62d1f 100%); background: -webkit-linear-gradient(top, #f24437 5%, #c62d1f 100%); background: -o-linear-gradient(top, #f24437 5%, #c62d1f 100%); background: -ms-linear-gradient(top, #f24437 5%, #c62d1f 100%); background: linear-gradient(to bottom, #f24437 5%, #c62d1f 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f24437', endColorstr='#c62d1f',GradientType=0); background-color: #f24437; outline: none;
}
.like-social .myButton:active { position: relative; top: 1px; outline: none;
}
.like-social .open_video_likes_div { width: 25%; margin: auto; background-color: #da382a; padding: 10px; box-shadow: 0px 4px 14px; font-size: 22px; font-weight: bolder; color: snow;
}
.like-social .open_video_likes_div i { font-size: 16px; vertical-align: super;
}
Like button with react - Script Codes JS Codes
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var LikeButton = function (_React$Component) { _inherits(LikeButton, _React$Component); // must super function LikeButton(props) { _classCallCheck(this, LikeButton); // state var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.state = { likeState: 'like', likeCount: 0, heart: 'fa fa-heart-o' }; return _this; } LikeButton.prototype.render = function render() { return React.createElement( 'div', { className: 'like-social' }, React.createElement( 'div', { className: 'open_video_likes' }, React.createElement( 'button', { className: 'myButton', onClick: this.changeState.bind(this) }, this.state.likeState, '!' ) ), React.createElement( 'div', { className: 'open_video_likes_div' }, React.createElement( 'span', { className: 'open_video_likes_count' }, ' ', this.state.likeCount, ' ' ), React.createElement('i', { className: this.state.heart }) ) ); }; LikeButton.prototype.changeState = function changeState(event) { if (this.state.likeState === 'like') { this.setState({ likeState: 'unlike', likeCount: this.state.likeCount + 1, heart: 'fa fa-heart' }); } else { this.setState({ likeState: 'like', likeCount: this.state.likeCount - 1, heart: 'fa fa-heart-o' }); } }; return LikeButton;
}(React.Component);
;
ReactDOM.render(React.createElement(LikeButton, null), document.getElementById('app'));
![Like button with react - Script Codes](http://shots.codepen.io/mohammed-fawzy/pen/ZJXoVJ-512.jpg)
Developer | Mohammed Fawzy |
Username | mohammed-fawzy |
Uploaded | January 26, 2023 |
Rating | 3 |
Size | 4,397 Kb |
Views | 8,096 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Place holder | 1,450 Kb |
Before page loading | 1,802 Kb |
Todo List with react | 3,687 Kb |
Full width to the odds div | 2,571 Kb |
A Pen by mohammed fawzy | 3,934 Kb |
Update text with react | 2,858 Kb |
Tab | 2,563 Kb |
Like button jQuery | 3,469 Kb |
JQuery Collapse | 4,096 Kb |
Tool Box | 3,036 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
3D-box | Parthviroja | 2,346 Kb |
Next Word Predictor | Rfalor | 2,776 Kb |
Disable JavaScript execution from console | Ludviglindblom | 2,534 Kb |
Subscription Newsletter - Before inlining | Bradstrong | 7,526 Kb |
Scifi-style Interative Form | Aaronchuo | 4,566 Kb |
Day 11 - Calendar Card | Arnellebalane | 6,984 Kb |
Get third wednesday | Wojtek1150 | 2,691 Kb |
Drifting Clouds | Benedikte | 2,247 Kb |
CSS3 Diamond | Rendro | 1,960 Kb |
Starfield old school style | Bolloxim | 5,214 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!