ReactJS(5)Composition vs Inheritance
Composition VS Inheritance
function FancyBorder(props){
return (
<div className={‘FancyBorder FacyBorder-‘ + props.color}> {props.children} </div>
);
}
function WelcomeDialog(){
return (
<FancyBorder color=“blue”>
<h1 className=“Dialog-title”> Welcome </h1>
<p className=“Dialog-message”> Thank you for visiting our spacecraft! </p>
</FancyBorder>
);
}
Anything inside the <FancyBorder> JSX tag gets passed into the FancyBorder component as a children prop.
Thinking in React
https://facebook.github.io/react/docs/thinking-in-react.html
Client Side
Checkout example project
https://github.com/jackhutu/jackblog-react
Start the project
>npm install
my npm version is 5.0.2
Start to debug
>npm start dev
Some small changes in the file
>git diff src/components/Toaster/index.js
- const { msg } = nextProps
- const { hideMsg } = this.props
+ const msg = nextProps
+ const hideMsg = this.props
Server Side
https://github.com/jackhutu/jackblog-api-express
>npm install
Start develop
>gulp serve
Exceptions:
events.js:182
throw er; // Unhandled 'error' event
^
Error: The module '/Users/carl/work/jackblog/jackblog-api-express/node_modules/ccap/build/Release/hcaptha.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Solution:
>sudo npm install -g gulp
Start Mongo and Redis
>bin/redis-server
>bin/mongod -f conf/mongodb.conf
Start the Server Side
>gulp serve
Read the Detail as well
https://github.com/jackhutu/jackblog-api-express.git
References:
https://facebook.github.io/react/docs/composition-vs-inheritance.html
https://facebook.github.io/react/docs/thinking-in-react.html
分享到:
相关推荐
AdapterDelegates, 用于RecyclerView适配器的"Favor composition over inheritance" AdapterDelegates阅读这个项目的动机在我的博客文章。依赖项这里库在 Maven 中心可用:compile '...
Chapter 5 Basic Definitions Chapter 6 Scalar Values with Inheritance Chapter 7 Scalar Variables with Inheritance Chapter 8 Specialization by Constraint etc. Chapter 9 Equality Comparisons etc. Chapter...
用c语言编写的遗传算法程序包,无需解压密码
PPT格式的文档 关于uml的课件,关于java的继承问题
YaViewDelegate: Composition over inheritance compile 'com.github.piasy:YaMvp:1.3.1' YaMvp-Rx RxJava Subscription management. compile 'com.github.piasy:YaMvp-Rx:1.3.1' YaRxDelegate: Comp
How do you choose between inheritance and templates? Between templates and generic pointers? Between public and private inheritance? Between private inheritance and layering? Between function ...
Basic manual of java for beginners with simple and easy descriptions. Inheritance, composition, collections, files, interfaces
Java编程继承Thread实现线程代码Java programming code inheritance Thread to Thread
ACE 类结构,用于描述ACE中各个类的继承关系!
inheritance10.rar
NULL 博文链接:https://butterflymacro.iteye.com/blog/1271789
Topic 10 Inheritance.md
inheritance_art.zip
介绍Java的封装继承和多态和java的一些基本特性
For developers with experience in any language, Victor Shtern’s Core C++ teaches C++ the right way: by applying the best software engineering ...inheritance, polymorphism, I/O, and much more.
Java从初学到精通电子教案:第7章 继承
Qt 类设计原则,内容不多,待续 – 面向接口编程而不是实现 (Code to an interface rather than to an implementation.) – 优先使用组合而非继承 (Favor Composition Over Inheritance)
It includes a useful list of core controls that will be useful for most UI needs, and its powerful composition and inheritance capabilites and event-driven architecture allow you to quickly and ...
沃丁顿. 1942. 渠化的发展与后天性状的遗传. 自然