SlideShare a Scribd company logo
1 of 26
React.js
A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES
2015/08/28
李佳駿
React.js
1. JUST THE UI
2. JSX
3. VIRTUAL DOM
4. DATA FLOW
JSX.js
JSX is a JavaScript syntax extension that looks
similar to XML.
You can use a simple JSX syntactic transform
with React .
JSX.js
透過 React 建立元件有兩種方式
React.DOM.div();
React.createElement('div');
JSX.js
<div id="myd">23</div>
React.DOM.div({id: 'myId'}, 23);
React.createElement('div', {id: 'myId'},23);
Use JSX.js :
<div>Hello John</div>
JSX.js
var HelloMessage =
React.createClass({displayName: "HelloMessage",
render: function()
{
return React.createElement("div",
null, "Hello ", this.props.name);
}
});
React.render(
React.createElement(
HelloMessage, {name: "John"}), mountNode);
JSX.js
var HelloMessage =
React.createClass({
render: function()
{
return <div>Hello {this.props.name}</div>;
}
});
React.render(<HelloMessage name="John" />, mountNode);
XSS 攻擊
XSS 的攻擊手法就是透過在我們的網頁中植入他
想要執行的指令碼,所以這個駭客手段才會被
稱為跨網站的指令碼 (Cross-Site-Scripting)
http://www.dotblogs.com.tw/jimmyyu/archive/20
09/04/21/8118.aspx
JSX Gotchas
You can insert HTML entities within literal text
in JSX:
First Second‧
<div>First &middot; Second</div>
If you want to display an HTML entity within
dynamic content, you will run into double escaping
issues as React escapes all the strings you are
displaying in order to prevent a wide range of XSS
attacks by default.
JSX Gotchas
<div>{'First &middot; Second'}</div>
// Bad: It displays "First &middot; Second"
1. You need to make sure that the file is saved as UTF-
8 and that the proper UTF-8 directives are set so
the browser will display it correctly.
<div>{'First Second'}</div>‧
JSX Gotchas
2. A safer alternative is to find the unicode number
corresponding to the entity and use it inside of a
JavaScript string.
<div>{'First u00b7 Second'}</div>
<div>{'First ' + String .fromCharCode(183) +
'Second'}</div>
JSX Gotchas
3. You can use mixed arrays with strings and JSX
elements.
<div>{['First ',
<span>&middot;</span>, ' Second']}</div>
4. As a last resort, you always have the ability to insert
raw HTML.
<div dangerouslySetInnerHTML=
{{__html: 'First &middot; Second'}} />
VIRTUAL DOM
var HelloMessage =
React.createClass({
render: function()
{
return <div>Hello {this.props.name}</div>;
}
});
React.render(<HelloMessage name="John" />, mountNode);
傳統的網頁應用程式中,我們如果要增加互動性時勢
必廣泛的操作 DOM 元素,一般來說現在最普遍的技
術是使用  jQuery:
React 的主要目標就是提供一種不同且更有效率的方式去執
行關於操作更新 DOM 這個部分,最終這個方式會取代我們
直接操作 DOM 的方法。
<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="//fb.me/react-0.13.1.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id = "content"></div>
</body>
</html>
React-1
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
); }});
React.render(
<CommentBox />,
document.getElementById('content'));
React-2
Jquery : $('#content')[0]
React-3
Hello, world! I am a CommentBox.
var CommentList = React.createClass({
render: function() {
return (
<div className="commentList">
Hello, world! I am a CommentList.
</div>
);
}
});
Composing components-1
var CommentForm = React.createClass({
render: function() {
return (
<div className="commentForm">
Hello, world! I am a CommentForm.
</div>
);
}
});
Composing components-2
var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
<h1>Comments</h1>
<CommentList />
<CommentForm />
</div>
);
}});
Composing components-3
Composing components-4
var CommentList = React.createClass({
render: function() { return (
<div className="commentList">
<Comment author="Pete Hunt">comment
</Comment>
<Comment author="Jordan Walke">another
</Comment>
</div> ); } });
Component Properties-1
var Comment = React.createClass({
render: function() { return (
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2>
{this.props.children}
</div>
); } });
Component Properties-2
Component Properties-3
http://jamestw.logdown.com/posts/248317-react-one-step-at-a-time
http://ithelp.ithome.com.tw/question/10156062
http://docs.reactjs-china.com/react/docs/jsx-gotchas.html

More Related Content

What's hot

MongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative SchemasMongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative Schemas
MongoDB
 
Cara membuka workbook yang terproteksi
Cara membuka workbook yang terproteksiCara membuka workbook yang terproteksi
Cara membuka workbook yang terproteksi
Irmaoly
 
Database madness with_mongoengine_and_sql_alchemy
Database madness with_mongoengine_and_sql_alchemyDatabase madness with_mongoengine_and_sql_alchemy
Database madness with_mongoengine_and_sql_alchemy
Jaime Buelta
 

What's hot (20)

MongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative SchemasMongoDB Indexing Constraints and Creative Schemas
MongoDB Indexing Constraints and Creative Schemas
 
Lodash js
Lodash jsLodash js
Lodash js
 
[PHP] Zend_Db (Zend Framework)
[PHP] Zend_Db (Zend Framework)[PHP] Zend_Db (Zend Framework)
[PHP] Zend_Db (Zend Framework)
 
Sequelize
SequelizeSequelize
Sequelize
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
 
Cara membuka workbook yang terproteksi
Cara membuka workbook yang terproteksiCara membuka workbook yang terproteksi
Cara membuka workbook yang terproteksi
 
Storing tree structures with MongoDB
Storing tree structures with MongoDBStoring tree structures with MongoDB
Storing tree structures with MongoDB
 
Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"
 
structure
structurestructure
structure
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Rental
RentalRental
Rental
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecases
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
 
Database madness with_mongoengine_and_sql_alchemy
Database madness with_mongoengine_and_sql_alchemyDatabase madness with_mongoengine_and_sql_alchemy
Database madness with_mongoengine_and_sql_alchemy
 
NoSQL - Hands on
NoSQL - Hands onNoSQL - Hands on
NoSQL - Hands on
 
Cookie and session
Cookie and sessionCookie and session
Cookie and session
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
 
Html web sql database
Html web sql databaseHtml web sql database
Html web sql database
 
03DOM.ppt
03DOM.ppt03DOM.ppt
03DOM.ppt
 

Viewers also liked (14)

20120601_Excel 元件 ep plus joncash
20120601_Excel 元件 ep plus joncash20120601_Excel 元件 ep plus joncash
20120601_Excel 元件 ep plus joncash
 
Ukraine export restrictions 653
Ukraine export restrictions 653Ukraine export restrictions 653
Ukraine export restrictions 653
 
Ukraine export restrictions 655
Ukraine export restrictions 655Ukraine export restrictions 655
Ukraine export restrictions 655
 
Ukraine export restrictions 658
Ukraine export restrictions 658Ukraine export restrictions 658
Ukraine export restrictions 658
 
Cabalgata 2 O1 O
Cabalgata 2 O1 OCabalgata 2 O1 O
Cabalgata 2 O1 O
 
Chistes
ChistesChistes
Chistes
 
Resolución 007 2015
Resolución 007 2015Resolución 007 2015
Resolución 007 2015
 
Ukraine export restrictions 652
Ukraine export restrictions 652Ukraine export restrictions 652
Ukraine export restrictions 652
 
Desarrollo del i examen parcial de instalaciones en edificaciones i
Desarrollo del i examen parcial de instalaciones en edificaciones iDesarrollo del i examen parcial de instalaciones en edificaciones i
Desarrollo del i examen parcial de instalaciones en edificaciones i
 
objeto
objetoobjeto
objeto
 
Borrador trabajo final_de_disenos
Borrador trabajo final_de_disenosBorrador trabajo final_de_disenos
Borrador trabajo final_de_disenos
 
Neuville mai 2012
Neuville mai 2012Neuville mai 2012
Neuville mai 2012
 
Histologia tecido conjuntivo especial, muscular e nervoso
Histologia tecido conjuntivo especial, muscular e nervosoHistologia tecido conjuntivo especial, muscular e nervoso
Histologia tecido conjuntivo especial, muscular e nervoso
 
Aula de Embriologia (UNESP - CLP)
Aula de Embriologia (UNESP - CLP)Aula de Embriologia (UNESP - CLP)
Aula de Embriologia (UNESP - CLP)
 

Similar to React.js 20150828

Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
IndicThreads
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
vhazrati
 

Similar to React.js 20150828 (20)

Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React Native
 
React js t2 - jsx
React js   t2 - jsxReact js   t2 - jsx
React js t2 - jsx
 
Introduction to React and MobX
Introduction to React and MobXIntroduction to React and MobX
Introduction to React and MobX
 
Academy PRO: React JS
Academy PRO: React JSAcademy PRO: React JS
Academy PRO: React JS
 
Understanding React JSX_ A Beginner's Guide
Understanding React JSX_ A Beginner's GuideUnderstanding React JSX_ A Beginner's Guide
Understanding React JSX_ A Beginner's Guide
 
Using react with meteor
Using react with meteorUsing react with meteor
Using react with meteor
 
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark BrocatoSenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
 
React js
React jsReact js
React js
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
React
React React
React
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
React JSX.pptx
React JSX.pptxReact JSX.pptx
React JSX.pptx
 
React.js workshop by tech47.in
React.js workshop by tech47.inReact.js workshop by tech47.in
React.js workshop by tech47.in
 

More from LearningTech (20)

vim
vimvim
vim
 
PostCss
PostCssPostCss
PostCss
 
ReactJs
ReactJsReactJs
ReactJs
 
Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Expression tree
Expression treeExpression tree
Expression tree
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection &amp; activator
Reflection &amp; activatorReflection &amp; activator
Reflection &amp; activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

React.js 20150828

Editor's Notes

  1. 上圖我們故意讓 DOM 示意為紅色這是因為操作更新 DOM 是需要付出昂貴的代價,也意味著這很吃效能。 很多時候我們會使用 Model 來記錄關於 APP 狀態,不過通常我們最後目標是必須要將狀態呈現給使用者,所以我們必須自己實作這些細節。 這已經是我們很稀鬆平常的開發模式。 上圖我們故意讓 DOM 示意為紅色這是因為操作更新 DOM 是需要付出昂貴的代價,也意味著這很吃效能。 很多時候我們會使用 Model 來記錄關於 APP 狀態,不過通常我們最後目標是必須要將狀態呈現給使用者,所以我們必須自己實作這些細節。 這已經是我們很稀鬆平常的開發模式。 上圖我們故意讓 DOM 示意為紅色這是因為操作更新 DOM 是需要付出昂貴的代價,也意味著這很吃效能。 很多時候我們會使用 Model 來記錄關於 APP 狀態,不過通常我們最後目標是必須要將狀態呈現給使用者,所以我們必須自己實作這些細節。 這已經是我們很稀鬆平常的開發模式。
  2. 為什麼多引進一層架構會讓效能增加? 如果在其架構之上多引入一層可以提升速度,這不是暗示瀏覽器並沒有實作最佳的 DOM 操作方式。 這也意味著虛擬 DOM 有著跟實際 DOM 不同的語義和行為。值得關注的是當我們改變虛擬 DOM 時並不能保證立即得到效果。 也因為這個機制導致 React 在實際接觸 DOM 之前必須要等待事件迴圈結束。在同一時間它會去計算最小差異並儘可能的用最少的步驟去更新 DOM。
  3. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  4. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  5. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  6. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  7. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  8. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  9. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  10. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  11. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。
  12. 這個範例建立了一個 React 元件的類別(class): HelloMessage,然後透過 renderComponent() 在虛擬的 DOM 的機制中建立一個元件(&amp;lt;HelloMessage /&amp;gt;, 本質上它就是 HelloMessage 類別實例化的物件,同時也是一個虛擬的 DOM) 最後把這個物件裝到真實的 DOM 元素(mountNode)。 首先是需要注意的事情是 React 的虛擬 DOM 通常來自您在應用程式中客制的元件(在這個例子是 &amp;lt;HelloMessage&amp;gt;)。這是一個意義重大的新嘗試,從內建的 DOM 分離出來。 DOM 通常不帶有任何程式邏輯,就只是一個被動的資料結構,且讓我們能夠附加處理事件。換句話說 React 的虛擬 DOM 是透過特定程式中的元件所創造的,且能夠加入程式中的特定 API 及內部邏輯。 這樣的方式比起直接修改操作 DOM ,例如: 使用 jQuery 的方式,這種建置 View 的方法是一種全新的抽象化方式與框架。