Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Intro to Reactjs
Search
Michael Lancaster
May 12, 2015
Technology
2.2k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Intro to Reactjs
A quick intro to React.js
Michael Lancaster
May 12, 2015
More Decks by Michael Lancaster
See All by Michael Lancaster
Docker?! But I'm a frontend.
weblancaster
3
530
Soundnode, The Journey
weblancaster
0
280
intro to javascript unit tests for client side
weblancaster
0
200
Desktop Apps with NW.js and Angular.js (updated)
weblancaster
9
2.4k
CSS the right way?
weblancaster
15
2.1k
Other Decks in Technology
See All in Technology
雪かき部 #7 もう怖くない!SELECT文!
foursue
0
270
なぜAI任せのゲームは面白くならないのか?
hirohasuyoutube
0
370
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
360
MCPゲートウェイを作って運用してわかったこと — Agent時代の権限管理の現在地
mtpooh
7
2.4k
企業の現実世界をグラフで写し取る
sansantech
PRO
0
230
全社共通データ基盤をつくる。ソニーのDatabricks活用とデータガバナンス設計の裏側
sony
0
280
「大丈夫そう?」をObservabilityで確かめる
mrmtsu
0
240
Terraformを用いたJamf Pro構成のIaC, GitOps化への挑戦
yukun
0
120
AI Made Us Faster at Solving the Wrong Problems
marceloancelmo
0
110
Meet AgentCore Identity Consent Portal
hironobuiga
2
140
覗いてみよう 関数型ビジュアル言語×2Dグラフィックスの世界
yohyamasaki
0
160
OpenClawでAzure DevOpsのWiki更新を自動化する - クラウドAIだけでは届かない場所へ
yutakaosada
0
140
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
890
Thoughts on Productivity
jonyablonski
76
5.4k
The Cult of Friendly URLs
andyhume
79
7k
A Tale of Four Properties
chriscoyier
163
24k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
510
Designing for Timeless Needs
cassininazir
1
510
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
The Invisible Side of Design
smashingmag
301
52k
Evolving SEO for Evolving Search Engines
ryanjones
0
300
Transcript
Intro to React.js
How a Chinese Company built a 57-storey skyscrapers in 19
days?
None
None
None
Composability Encapsulation Reusability Declarative Flexibility Performance Interoperability
None
JSX
import React from "react"; import ReactDOM from "react-dom"; class App
extends React.Component { constructor(props) { super(props); this.state = { todos: ['buy soy milk', 'call mom'] } } render() { return (<div><Todos todos={this.state.todos} /></div>) } } const Todos = ({todos}) => { return ( <ul> {todos.map(todo => { return <TodoItem key={todo.replace(' ', ‘’)} todo={todo} /> })} </ul> ) }; const TodoItem = ({todo}) => (<li>{todo}</li>); const rootElement = document.getElementById("root"); ReactDOM.render(<App />, rootElement);
None
Compiled
var App = (function(_React$Component) { _inherits(App, _React$Component); function App(props) {…}
_createClass(App, [ { key: "render", value: function render() { return React.createElement( "div", null, React.createElement(Todos, { todos: this.state.todos }) ); } } ]); return App; })(React.Component); var Todos = function Todos(_ref) { var todos = _ref.todos; return React.createElement( "ul", null, todos.map(function(todo) { return React.createElement(TodoItem, { key: todo.replace(" ", ""), todo: todo }); }) ); }; var TodoItem = function TodoItem(_ref2) { var todo = _ref2.todo; return React.createElement("li", null, todo); };
import React from "react"; import ReactDOM from "react-dom"; class App
extends React.Component { constructor(props) { super(props); this.state = { todos: ['buy soy milk', 'call mom'] } } render() { return (<div><Todos todos={this.state.todos} /></div>) } } const Todos = ({todos}) => { return ( <ul> {todos.map(todo => { return <TodoItem key={todo.replace(' ', ‘’)} todo={todo} /> })} </ul> ) }; const TodoItem = ({todo}) => (<li>{todo}</li>); const rootElement = document.getElementById("root"); ReactDOM.render(<App />, rootElement);
Diff Algorithm
Level by Level * source http://calendar.perfplanet.com/2013/diff/
Components * source http://calendar.perfplanet.com/2013/diff/
List * source http://calendar.perfplanet.com/2013/diff/
Batching * source http://calendar.perfplanet.com/2013/diff/
Sub-tree rendering * source http://calendar.perfplanet.com/2013/diff/
Selective Sub-tree rendering * source http://calendar.perfplanet.com/2013/diff/
Component Lifecycle
Mounting Update (new props or state) constructor() static getDerivedStateFromProps() render()
componentDidMount() static getDerivedStateFromProps() shouldComponentUpdate() render() getSnapshotBeforeUpdate() componentDidUpdate() Unmounting componentWillUnmount() Error Handling static getDerivedStateFromError() componentDidCatch()
Props vs State
- Props State Can get initial value from parent Component?
Yes Yes Can be changed by parent Component? Yes No Can set default values inside Component? Yes Yes Can change inside Component? No Yes Can set initial value for child Components? Yes Yes
React-Native React-Native-Web React-Primitives React-Sketch React-360 React-Native-Windows
Demo
Thanks!