TweetBox with React JS

Developer
Size
3,325 Kb
Views
22,264

How do I make an tweetbox with react js?

First contact with React JS through the creation of a Twitter Tweet Box. What is a tweetbox with react js? How do you make a tweetbox with react js? This script and codes were developed by Jose Sentis on 08 September 2022, Thursday.

TweetBox with React JS Previews

TweetBox with React JS - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>TweetBox with React JS</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="app" class="container"> <div id="container">Hola</div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

TweetBox with React JS - Script Codes CSS Codes

body { padding: 30px 0; color: #000; background-color: #f2f2f2;
}

TweetBox with React JS - Script Codes JS Codes

"use strict";
var TweetBox = React.createClass({ displayName: "TweetBox", getInitialState: function getInitialState() { return { text: "", photoAdded: false, maxChar: 140 }; }, handleChange: function handleChange(event) { this.setState({ text: event.target.value }); }, togglePhoto: function togglePhoto(event) { this.setState({ photoAdded: !this.state.photoAdded }); }, remainingCharacters: function remainingCharacters() { if (this.state.photoAdded) { return 140 - 23 - this.state.text.length; } else { return 140 - this.state.text.length; } }, overflowAlert: function overflowAlert() { if (this.remainingCharacters() < 0) { if (this.state.photoAdded) { var beforeOverflowText = this.state.text.substring(140 - 23 - 10, 140 - 23); var overflowText = this.state.text.substring(140 - 23); } else { var beforeOverflowText = this.state.text.substring(140 - 10, 140); var overflowText = this.state.text.substring(140); } return React.createElement( "div", { className: "alert alert-warning" }, React.createElement( "strong", null, "Oops! Too Long:" ), " ...", beforeOverflowText, React.createElement( "strong", { className: "bg-danger" }, overflowText ) ); } else { return ""; } }, render: function render() { return React.createElement( "div", { className: "well clearfix" }, this.overflowAlert(), React.createElement("textarea", { className: "form-control", onChange: this.handleChange }), React.createElement("br", null), React.createElement( "span", null, this.remainingCharacters() ), React.createElement( "button", { className: "btn btn-primary pull-right", disabled: this.remainingCharacters() === 140 }, "Tweet" ), React.createElement( "button", { className: "btn btn-default pull-right", onClick: this.togglePhoto }, this.state.photoAdded ? "✓ Photo Added" : "Add Photo" ) ); }
});
ReactDOM.render(React.createElement(TweetBox, null), document.getElementById("container"));
TweetBox with React JS - Script Codes
TweetBox with React JS - Script Codes
Home Page Home
Developer Jose Sentis
Username j0zelito
Uploaded September 08, 2022
Rating 3
Size 3,325 Kb
Views 22,264
Do you need developer help for TweetBox with React JS?

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!

Jose Sentis (j0zelito) Script Codes
Create amazing blog posts with AI!

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!