- 浏览: 2552358 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
ReactJS(1)Begin from the Starter
Create the Project to show the diagram for Monitor Job Count
> git clone -o react-starter-kit -b master --single-branch https://github.com/kriasoft/react-starter-kit.git JobCountMonitor
Check ENV
>node --version && npm --version
v6.10.0
3.10.10
> yarn --version
0.20.3
> yarn install
This command will install he dependencies and tools in package.json
> yarn start
This command will build the src to build. It will start Node.js Server (no build/server.js) and Browsersync with HMR.
The outputs are as follow:
http://localhost:3000/ Node.js server (build/server.js)
http://localhost:3000/graphql - GraphQL server and IDE
http://localhost:3001/ BrowserSync proxy with HMR, React Hot Transform
http://localhost:3002/ BrowserSync control panel (UI)
Start the Project in Release module
> yarn start --release
Build the Project
> yarn run build
Build release Version
> yarn run build -- --release
On my MAC, I did not install docker.
> yarn run build -- --release --docker
Check the Syntax
> yarn run lint
Unit tests with Mocha
> yarn run test
run the tests and watch for changes
> yarn run test:watch
Start with ReactJS
https://facebook.github.io/react/docs/installation.html
Introducing JSX - I guess it is JavaScript Extension
const element = <h1>hello</h1>;
Embedding JavaScript expressions in curly braces.
We can try the code online in https://codepen.io/login
A very simple example is as follow:
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
const user = {
firstName: 'Carl',
lastName: 'Luo'
};
const element = (
<h1>
Hello, {formatName(user)}!
</h1>
);
ReactDOM.render(
element,
document.getElementById('root')
);
You should either use quotes(for string values) or curly braces(for expressions), but not both in the same attribute.
JSX Represents Objects
const element = (
<h1 className=“greeting”>
Hello
</h1>
);
the same as
const element = React.createElement(
‘h1’,
{className: ‘greating’},
‘Hello'
);
React reads these objects and uses them to construct the DOM.
https://facebook.github.io/react/docs/rendering-elements.html
Upgrade the my nodeJS to latest version
All different versions
https://nodejs.org/en/download/current/
on Mac
>wget https://nodejs.org/dist/v8.0.0/node-v8.0.0.tar.gz
configure and make and make install
>node --version && npm --version
v8.0.0
5.0.0
on CentOS
>wget https://nodejs.org/dist/v8.0.0/node-v8.0.0.tar.gz
Prepare the ENV
>sudo yum install gcc gcc-c++
configure and make and make install
> node --version && npm --version
v8.0.0
5.0.0
on RaspberryPI - Directly Use Binary
I believe my RaspberryPI is arm7
>wget https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-armv7l.tar.xz
unzip the binary file
>tar xf node-v8.0.0-linux-armv7l.tar.xz
Move it to the working directory
>mv node-v8.0.0-linux-armv7l ~/tool/node-v8.0.0
>sudo ln -s /home/carl/tool/node-v8.0.0 /opt/node-v8.0.0
>sudo ln -s /opt/node-v8.0.0 /opt/node
Add bin to the PATH, check the installation
>node --version
v8.0.0
>npm --version
5.0.0
const element = <h1>Hello</h1>;
unlike browser DOM elements, react elements are plain objects, cheap to create.
React DOM takes care of updating the DOM to match the React elements.
<div id=“root”></div> That is a “root” DOM node. All the thing inside will be managed by React DOM.
to render a React element into a root DOM.
const element = <h1>Hello</h1>;
ReactDOM.render(
element,
document.getElementById(‘root');
);
React elements are immutable. Once it is created, we can not change it. An element is like a single frame in a movie.
Updating look and feel will be pass new element to the ReactDOM.render().
Components and Props
function Welcome(props){
return <h1>Hello, {props.name}</h1>;
}
is as the same as
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
Define the element, function and ReactDOM
function Welcome1(props) {
return <h1>Hello, {props.name}</h1>;
}
const element = <Welcome1 name="Carl" />;
ReactDOM.render(
element,
document.getElementById('root')
);
Steps for that, ReactDOM.render() render the element <Welcome1 name=“Carl” />, React call the Welcome1 component with {name:’Carl’} as the props. Welcome1 component returns a <h1>Hello, Carl</h1> element to ReactDOM.
Always start component names with a Capital Letter.
Composing Components
Components can call components.
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
function App() {
return (
<div>
<Welcome name="Carl" />
<Welcome name="Kiko" />
<Welcome name="Leo" />
</div>
);
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
Typically, new React apps should have single App component that the very top.
References:
https://github.com/kriasoft/react-starter-kit/blob/master/docs/getting-started.md
https://github.com/kriasoft/react-starter-kit
https://facebook.github.io/react/docs/introducing-jsx.html
Create the Project to show the diagram for Monitor Job Count
> git clone -o react-starter-kit -b master --single-branch https://github.com/kriasoft/react-starter-kit.git JobCountMonitor
Check ENV
>node --version && npm --version
v6.10.0
3.10.10
> yarn --version
0.20.3
> yarn install
This command will install he dependencies and tools in package.json
> yarn start
This command will build the src to build. It will start Node.js Server (no build/server.js) and Browsersync with HMR.
The outputs are as follow:
http://localhost:3000/ Node.js server (build/server.js)
http://localhost:3000/graphql - GraphQL server and IDE
http://localhost:3001/ BrowserSync proxy with HMR, React Hot Transform
http://localhost:3002/ BrowserSync control panel (UI)
Start the Project in Release module
> yarn start --release
Build the Project
> yarn run build
Build release Version
> yarn run build -- --release
On my MAC, I did not install docker.
> yarn run build -- --release --docker
Check the Syntax
> yarn run lint
Unit tests with Mocha
> yarn run test
run the tests and watch for changes
> yarn run test:watch
Start with ReactJS
https://facebook.github.io/react/docs/installation.html
Introducing JSX - I guess it is JavaScript Extension
const element = <h1>hello</h1>;
Embedding JavaScript expressions in curly braces.
We can try the code online in https://codepen.io/login
A very simple example is as follow:
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
const user = {
firstName: 'Carl',
lastName: 'Luo'
};
const element = (
<h1>
Hello, {formatName(user)}!
</h1>
);
ReactDOM.render(
element,
document.getElementById('root')
);
You should either use quotes(for string values) or curly braces(for expressions), but not both in the same attribute.
JSX Represents Objects
const element = (
<h1 className=“greeting”>
Hello
</h1>
);
the same as
const element = React.createElement(
‘h1’,
{className: ‘greating’},
‘Hello'
);
React reads these objects and uses them to construct the DOM.
https://facebook.github.io/react/docs/rendering-elements.html
Upgrade the my nodeJS to latest version
All different versions
https://nodejs.org/en/download/current/
on Mac
>wget https://nodejs.org/dist/v8.0.0/node-v8.0.0.tar.gz
configure and make and make install
>node --version && npm --version
v8.0.0
5.0.0
on CentOS
>wget https://nodejs.org/dist/v8.0.0/node-v8.0.0.tar.gz
Prepare the ENV
>sudo yum install gcc gcc-c++
configure and make and make install
> node --version && npm --version
v8.0.0
5.0.0
on RaspberryPI - Directly Use Binary
I believe my RaspberryPI is arm7
>wget https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-armv7l.tar.xz
unzip the binary file
>tar xf node-v8.0.0-linux-armv7l.tar.xz
Move it to the working directory
>mv node-v8.0.0-linux-armv7l ~/tool/node-v8.0.0
>sudo ln -s /home/carl/tool/node-v8.0.0 /opt/node-v8.0.0
>sudo ln -s /opt/node-v8.0.0 /opt/node
Add bin to the PATH, check the installation
>node --version
v8.0.0
>npm --version
5.0.0
const element = <h1>Hello</h1>;
unlike browser DOM elements, react elements are plain objects, cheap to create.
React DOM takes care of updating the DOM to match the React elements.
<div id=“root”></div> That is a “root” DOM node. All the thing inside will be managed by React DOM.
to render a React element into a root DOM.
const element = <h1>Hello</h1>;
ReactDOM.render(
element,
document.getElementById(‘root');
);
React elements are immutable. Once it is created, we can not change it. An element is like a single frame in a movie.
Updating look and feel will be pass new element to the ReactDOM.render().
Components and Props
function Welcome(props){
return <h1>Hello, {props.name}</h1>;
}
is as the same as
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
Define the element, function and ReactDOM
function Welcome1(props) {
return <h1>Hello, {props.name}</h1>;
}
const element = <Welcome1 name="Carl" />;
ReactDOM.render(
element,
document.getElementById('root')
);
Steps for that, ReactDOM.render() render the element <Welcome1 name=“Carl” />, React call the Welcome1 component with {name:’Carl’} as the props. Welcome1 component returns a <h1>Hello, Carl</h1> element to ReactDOM.
Always start component names with a Capital Letter.
Composing Components
Components can call components.
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
function App() {
return (
<div>
<Welcome name="Carl" />
<Welcome name="Kiko" />
<Welcome name="Leo" />
</div>
);
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
Typically, new React apps should have single App component that the very top.
References:
https://github.com/kriasoft/react-starter-kit/blob/master/docs/getting-started.md
https://github.com/kriasoft/react-starter-kit
https://facebook.github.io/react/docs/introducing-jsx.html
发表评论
-
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 241MongoDB 2019(3)Security and Aut ... -
Memory Leak in NodeJS
2018-12-20 06:26 736Memory Leak in NodeJS I have d ... -
Remote Desktop Client
2018-12-07 13:19 1200Remote Desktop Client There is ... -
MetaBase UI Console(2)Docker on MySQL
2018-11-29 06:58 944MetaBase UI Console(2)Docker on ... -
AWS Lambda and Serverless Timeout
2018-09-20 01:20 629AWS Lambda and Serverless Timeo ... -
2018 WebSocket(1)Introduction
2018-03-20 01:22 11102018 WebSocket(1)Introduction ... -
2018 TypeScript Update(3)Introduction Basic Grammar
2018-03-08 03:08 6092018 TypeScript Update(3)Introd ... -
2018 TypeScript Update(2)Introduction Basic Grammar - Classes and Functions
2018-03-06 05:32 5592018 TypeScript Update(2)Introd ... -
2018 TypeScript Update(1)Introduction Basic Grammar - Types and Interface
2018-03-03 01:15 6052018 TypeScript Update(1)Introd ... -
Charts and Console(6)Paging
2018-03-01 00:12 586Charts and Console(6)Paging Th ... -
Vue.JS(3)Google Login
2018-02-14 04:53 1317Vue.JS(3)Google Login I just p ... -
Vue.JS(2)Monitor Water Console - ChartJS and Axios
2018-02-14 03:17 726Vue.JS(2)Monitor Water Console ... -
Vue.JS(1)Introduction and Basic Demo
2018-02-08 06:47 615Vue.JS(1)Introduction and Basic ... -
Charts and Console(5)Validation Form
2017-10-03 05:12 811Charts and Console(5)Validation ... -
Charts and Console(4)Display and Enhancement
2017-09-20 05:39 639Charts and Console(4)Display an ... -
Charts and Console(3)Auth and Login
2017-09-13 03:45 667Charts and Console(3)Auth and L ... -
Charts and Console(2)Login and Proxy
2017-08-31 05:39 878Charts and Console(2)Login and ... -
Charts and Console(1)UI Console and RESTful Client
2017-08-29 11:02 771Charts and Console(1)UI Console ... -
Blog Project(2)Express Backend API - istanbul - mocha - bunyan
2017-06-09 00:05 485Blog Project(2)Express Backend ... -
ReactJS(5)Composition vs Inheritance
2017-06-06 05:55 1117ReactJS(5)Composition vs Inheri ...
相关推荐
U盘安装Centos7过程,启动时卡在press the enter key to begin the installation process 就不动弹了。下载附件替换掉/syslinux/vesamenu.c32即可解决。
Understand the social aspects of professional development, and build career-ready skills from the start Whether you’re a total beginner or you’ve tried before, Begin to Code with Python will put the...
With the Sublime Text 2 Starter, you will learn everything you need to know to begin using Sublime Text 2 and some of its more advanced features. This will provide you an excellent start on utilizing ...
Node.js is a platform that lets you use JavaScript to easily program scalable network applications and web services....Instant Node.js Starter will begin with installation and your first Hello World ...
As you complete each one, you'll have gained key skills and get ready for the material in the next module.The first module will begin with exploring all the essentials of Python programming in an ...
-on the server running tcp.exe, another in the same network with the client running on tcplnk.exe require the same port, on the server begin, the client server on the importation of the IP address, ...
三年级上册英语剑桥Join in版Starter unit Let's begin 单元测试卷.pdf
Product Description ...By the time you’ve finished the book, you will have mastered the core techniques and have all the knowledge you need to begin work as a professional ASP.NET developer.
This book is an outgrowth of a 1996 NIPS workshop called Tricks of the Trade whose goal was to begin the process of gathering and documenting these tricks. The interest that the workshop generated, ...
1. **style.css**:这是主题的样式表,定义了布局、颜色、字体等视觉元素。学习者需要理解CSS选择器、盒模型以及响应式设计的概念。 2. **header.php**:包含了页面顶部的内容,如网站标题、导航菜单等。这里会涉及...
"in addition", "in the first place", "in the past", "last", "lately", "meanwhile", "moreover", "next", "now", "presently", "second", "shortly", "simultaneously" 用于表明事件或想法的时间顺序:"Before ...
《WordPress杂志主题知更鸟Begin最新版LTS详解》 在WordPress的世界里,主题是构建网站外观和用户体验的关键元素。本文将深入探讨“知更鸟Begin”这一热门杂志主题的最新LTS(长期支持)版本,揭示其核心特性和优势...
From the Back Cover This multivolume work on the analysis of algorithms has long been recognized as the definitive description of classical computer science. The three complete volumes published to ...
We begin with choosing two random large distinct primes p and q. We also pick e, a random integer that is ...From one of the theorems of Euler s, we know that for all integers m, med = m (mod n)
该书的作者Stephen Covey将高度有效的人士的行为模式总结为七个习惯,分别是:Be Proactive、Begin with the End in Mind、Put First Things First、Think Win-Win、Seek First to Understand, Then to be ...
Because the router has the entire packet at time t1, it can begin to transmit the packet to the receiving host at time t1. At time t2 = t1 + L/R2, the router completes transmission and the entire ...