Component Props
How do I make an component props?
What is a component props? How do you make a component props? This script and codes were developed by Ruslan Marin on 07 December 2022, Wednesday.
Component Props - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Component Props</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="root"></div> <script src='https://npmcdn.com/[email protected]/dist/react.min.js'></script>
<script src='https://npmcdn.com/[email protected]/dist/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Component Props - Script Codes CSS Codes
body { background: rgba(0, 102, 255, .38); font-family: sans-serif;
}
p { margin: 0 0 1em;
}
article { background: #fff; border: 1px solid rgba(0, 89, 181, .82); width: 50em; margin: 0 0 .5em; box-shadow: 2px 2px 5px -1px rgb(0, 81, 202); padding: 0.5em 1em;
}
.header { text-align: left;
}
.content { text-align: left;
}
.news-author { font-weight: bold; color: #007ddc;
}
.news-text { font-style: italic;
}
.none { display: none !important;
}
Component Props - Script Codes JS Codes
"use strict";
var Article = React.createClass({ displayName: "Article", render: function render() { var article = this.props.data; return React.createElement( "article", { className: "content" }, React.createElement( "span", { className: "news-author" }, article.author, ": " ), React.createElement( "span", { className: "news-text" }, article.text ) ); }
});
var News = React.createClass({ displayName: "News", render: function render() { var data = this.props.newsdata; var newsTemplate; if (data.length > 0) { newsTemplate = data.map(function (item, index) { return React.createElement(Article, { data: item }); }); } else { newsTemplate = React.createElement( "p", null, "No news" ); } return React.createElement( "div", null, React.createElement( "div", null, newsTemplate ), React.createElement( "div", { className: data.length > 0 ? "" : "none" }, "Всего новостей: ", data.length ) ); }
});
var Comments = React.createClass({ displayName: "Comments", render: function render() { return React.createElement( "p", { className: "content" }, "No comments yet" ); }
});
var newsData = [{ author: "RM", text: "Something has happened" }, { author: "RM", text: "Something else has happened" }, { author: "Admin", text: "All our servers are down" }];
var App = React.createClass({ displayName: "App", render: function render() { return React.createElement( "section", null, React.createElement( "h3", { className: "header" }, "News" ), React.createElement(News, { newsdata: newsData }), " ", React.createElement(Comments, null) ); }
});
var container = document.getElementById('root');
ReactDOM.render(React.createElement(App, null), container);
Developer | Ruslan Marin |
Username | marinru |
Uploaded | December 07, 2022 |
Rating | 3 |
Size | 3,113 Kb |
Views | 14,168 |
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 |
Rotating Cube with p5.js | 2,148 Kb |
BnW | 1,489 Kb |
SimplePager | 4,584 Kb |
Vue 001. Hello World | 1,438 Kb |
P5.js Clock | 2,414 Kb |
Simple Component Example 2 | 2,099 Kb |
Vue.js User Input | 1,565 Kb |
Sidescroller with p5.js | 2,455 Kb |
Component State | 3,702 Kb |
Vue.js Attribute Binding | 1,531 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 |
Animated rainbow wave on canvas | Icodeforlove | 2,777 Kb |
Parallax scrolling scene | Iharosi | 2,485 Kb |
A Pen by Ash | Littleginger | 2,386 Kb |
Canvas stripes | Adrianparr | 1,948 Kb |
Testing Portfolio Page | Sideshowli | 3,395 Kb |
Simple Login Form | JoshBlackwood | 4,418 Kb |
Weird glowy CSS3 game | Toneworm | 3,684 Kb |
Old calculator | Gnarfugh | 2,815 Kb |
Hoi hoi | JohnTheCat | 7,248 Kb |
Kut D3 | Jellevrswk | 3,687 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!