Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[React Meetup Campinas 2017] Porque React criou...
Search
Talysson de Oliveira Cassiano
May 10, 2017
Programming
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
[React Meetup Campinas 2017] Porque React criou uma revolução - e você devia saber disso
Talysson de Oliveira Cassiano
May 10, 2017
More Decks by Talysson de Oliveira Cassiano
See All by Talysson de Oliveira Cassiano
[DDD Europe 2026] So you want to be a DDD practitioner
talyssonoc
0
52
[Tropical on Rails 2026] Privacy on Rails
talyssonoc
1
84
[Nerdearla Argentina 2025] LLMs as domain experts
talyssonoc
0
53
[TDC SP 2025] Então você quer ser um praticante de DDD
talyssonoc
0
69
[DDD Brasil] Então você quer ser um praticante de DDD
talyssonoc
0
46
[Rails World 2025 Lighting Talks] Where is it?! - Avoiding the XY Problem
talyssonoc
0
49
[TDC Floripa 2025] Abordagens funcionais efetivas em TypeScript com Effect-TS
talyssonoc
0
110
[TDC Floripa 2025] Modelagem de domínios como construção de teorias
talyssonoc
0
91
[Encontro GURU-SP e ELUG] Ruby on Fails - Tratamento de erros de maneira efetiva e com convenções do Rails
talyssonoc
0
69
Other Decks in Programming
See All in Programming
Foundation Models frameworkで画像分析
ryodeveloper
1
130
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
540
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
0
300
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3k
AI がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
230
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
630
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
500
Claude Team Plan導入・ガイド
tk3fftk
0
220
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
430
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
410
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
140
自作OSでスライド発表する
uyuki234
1
3.9k
Featured
See All Featured
Odyssey Design
rkendrick25
PRO
2
730
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Leo the Paperboy
mayatellez
8
1.9k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Google's AI Overviews - The New Search
badams
0
1.1k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
How to Ace a Technical Interview
jacobian
281
24k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.4k
Transcript
Porquê o React criou uma revolução E você devia saber
disso
Talysson @talyssonoc talyssonoc.github.io Front-end Codeminer42
React?!
“ Uma biblioteca JavaScript para construir interfaces de usuário. -
React, Documentação do
C M V
C M
¡Viva la revolución reacción!
Componentização
class GreetMessage extends React.Component { render() { return ( <div>
Hey, { this.props.name }. </div> ); } } ReactDOM.render( <GreetMessage name="Meetup attendant"/>, document.querySelector('#app') );
Antes // app.js angular.module('meetup', []) .controller('GreetCtrl', function($scope) { $scope.name =
'Meetup attendant'; }); // app.html <div ng-controller="GreetCtrl"> Hey, {{ name }}. </div> // app.js App.GreetMsgView = Ember.View.extend({ templateName: 'greet_msg' }); App.HomePageView = Ember.View.extend({ templateName: 'home_page', name: 'Meetup speaker' }); // home_page template {{#view 'greet_msg'}} // greet_msg template Hello, {{name}} Angular < 1.5 Ember 1.x
Depois // app.js angular.module('meetup', []) .controller('GreetCtrl', function($scope) { $scope.name =
'Meetup attendant'; }) .component('greetMsg', { template: 'Hey, {{ $ctrl.name }}.', bindings: { name: '=' } }); // app.html <div ng-controller="GreetCtrl"> <greet-msg name="name"></greet-msg> </div> // app.js App.GreetMsgComponent = Ember.Component.extend({ templateName: 'greet_msg' }); App.HomePageView = Ember.View.extend({ templateName: 'home_page', name: 'Meetup speaker' }); // home_page template {{greet-msg name=name}} // greet_msg template Hello, {{name}} Angular 1.5+ Ember 2.x
Composição
class GreetMessage extends React.Component { render() { return ( <div>
Hey, { this.props.name }. </div> ); } } class HomePage extends React.Component { render() { return ( <div> <h1>Welcome</h1> <GreetMessage name="Meetup attendant"/> </div> ); } } ReactDOM.render( <HomePage />, document.querySelector('#app') );
Antes Angular 1.x // greetMsg.js angular.module('meetup') .component('greetMsg', { bindings: {
name: '=' }, template: ` <div ng-click="$ctrl.handleClick()"> Hey, {{$ctrl.name}} </div>`, controller() { this.handleClick = function() { this.name = 'speaker'; }; } }); // homePage.js angular.module('meetup') .component('homePage', { template: ` <h1>{{$ctrl.theName | uppercase}}</h1> <greet-msg name="$ctrl.theName"></greet-msg> `, controller() { this.theName = 'attendant'; } });
Antes Backbone var HomePageView = Backbone.View.extend({ initialize: function() { this.greetAttendants
= new GreetMsgView({ model: { name: 'attendants'} }); this.greetSpeakers = new GreetMsgView({ model: { name: 'speakers'} }); }, render: function() { this.$el.append( this.greetAttendants.render().$el, this.greetSpeakers.render().$el ); } });
Depois Angular 2.x // greetMsg.ts @Component({ selector: 'greet-msg', template: `
<div (click)="handleClick()"> Hey, {{ name }} </div> ` }) export class GreetMsg { @Input() name = ''; handleClick() { this.name = 'speakers'; } } // homePage.ts @Component({ selector: 'home-page', directives: [GreetMsg], template: ` {{ theName | uppercase }} <greet-msg [name]="theName"></greet-msg> `, }) export class HomePage { constructor() { this.theName = 'attendants'; } }
Depois Backbone ¯\_(ツ)_/¯
Funcional
const makeBoldComponent = (Component) => { return (props) => <b><Component
{...props}/></b>; }; const GreetMessage = (props) => ( <div> Hey, { props.name }. </div> ); const BoldGreetMessage = makeBoldComponent(GreetMessage); const HomePage = () => ( <div> <h1>Welcome</h1> <BoldGreetMessage name="Meetup attendant"/> </div> ); ReactDOM.render( <HomePage />, document.querySelector('#app') );
Vantagens ▸ Favorece imutabilidade e pureza ▸ Código mais limpo
e menos classes ▸ Componentes de alta ordem ▸ Reduz uso do this ▸ Mais fácil de testar ▸ Melhor performance ▸ Memoização
Antes Angular Ember Backbone Vue Knockout
Depois CycleJS Elm Reagent Om Om Deku
Fluxo único de dados
Controller Model View Antes
Action Data Component Depois
Vantagens ▸ Maior previsibilidade ▸ Mais fácil de pensar sobre
▸ Mais fácil de encontrar causa de bugs ▸ Maior escalabilidade no front-end
CycleJS Elm Redux Flux Vuex X Ember 2 Data ⬇,
actions ⬆ Relay
Virtual DOM & Tree diff V-DOM
V-DOM
Preact V-DOM Ember 2/Glimmer CycleJS RiotJS Mithril Vue 2 Inferno
Elm
React/JSX é só JavaScript
“ Interfaces de usuário são simplesmente projeções de uma forma
de dado em outra forma de dado.
Antes <ul> <li ng-repeat="item in items"> <a ng-href="{{ item.url }}">
{{ item.title }} <span ng-if="item.subtitle"> - {{ item.subtitle }} </span> </a> </li> </ul> <ul> <li v-for="item in items"> <a v-bind:href="{{ item.url }}"> {{ item.title }} <span v-if="item.subtitle"> - {{ item.subtitle }} </span> </a> </li> </ul> Angular 1.x Vue
Antes <ul> {{#each item in items}} <li> {{#link-to 'items.show' item}}
{{ item.title }} {{#if item.subtitle }} - {{ item.subtitle }} {{/if}} {{/link-to}} </li> {{/each}} </ul> Ember/Handlebars
React com JSX <ul> { items.map((item) => ( <li> <a
href={ item.url }> { item.title } { item.subtitle && `- ${ item.subtitle }` } </a> </li> )) } </ul> const linkItems = items.map((item) => ( <li> <a href={ item.url }> { item.title } { item.subtitle && `- ${ item.subtitle }` } </a> </li> )); <ul> { linkItems } </ul>
React sem JSX const h = React.createElement; h('ul', null, items.map((item)
=> ( h('li', null, h('a', { href: item.url }, item.title, item.subtitle && `- ${ item.subtitle }` ) ) )) ); const h = React.createElement; const linkItems = items.map((item) => ( h('li', null, h('a', { href: item.url }, item.title, item.subtitle && `- ${ item.subtitle }` ) ) )); h('ul', null, linkItems );
Depois h('ul', items$.map((item) => ( h('li', h('a', { href: item.url
}, [ item.title, item.subtitle && `- ${ item.subtitle }` ]) ))) ); CycleJS <ul> { items.map((item) => ( <li> <a href={ item.url }> { item.title } { item.subtitle && `- ${ item.subtitle }` } </a> </li> )) } </ul> Inferno
Depois m('ul', items.map((item) => ( m('li', m('a', { href: item.url
}, [ item.title, item.subtitle && `- ${ item.subtitle }` ]) ))) ); Mithril <ul> { items.map((item) => ( <li> <a href={ item.url }> { item.title } { item.subtitle && `- ${ item.subtitle }` } </a> </li> )) } </ul> Preact
Interoperabilidade
None
Vantagens ▸ Adoção gradual, sem reescrita ▸ Integração simples, é
só JavaScript ▸ Biblioteca focada em UI ▸ Tamanho permite ser usada em conjunto (44kb)
Renderização do front-end no server
O problema ▸ Não-SPAs carregam mais que o necessário ▸
SPAs demoram para fazer o primeiro render ▸ SPAs tem problemas com SEO (sem hacks)
A solução ▸ Renderizar o máximo do front-end no servidor
▸ “Montar” a aplicação no HTML já renderizado ▸ Carregar apenas dados a partir daí ▸ Primeira tentativa: Backbone Rendr
Com React const html = ReactDOMServer.render( <HomePage /> ); ReactDOM.render(
<HomePage />, document.querySelector('#app') ); Servidor Cliente
CycleJS Vue 2 Ember FastBoot Angular Universal
Mundo mobile
Antes: o problema ▸ Manter várias aplicações mobile inteiras é
custoso ▸ Soluções híbridas com WebView são ineficazes ▸ O mercado mobile exige apps para todos SOs
import { View, Text } from 'react-native'; const GreetMessage =
(props) => ( <Text>Hey, { props.name }</Text> ); class GreetMobileDeveloper extends Component { render() { return ( <View> <GreetMessage name="Meetup mobile developer" /> </View> ); } } Com React Native
ReactXP Depois
O futuro
create-react-app ▸ CLI para desenvolvimento com React ▸ Tooling totalmente
configurado ▸ Já vem com suporte a testes ▸ Fácil para começar a produzir na hora
React Fiber ▸ Algoritmo de renderização incremental ▸ Mudança no
agendamento da renderização ▸ Possibilidade de renderizar via stream ▸ Renderização no servidor (ainda) mais efetiva ▸ Fragments
O React-way ▸ Componentes isolados, combináveis e reutilizáveis ▸ Fluxo
único de dados ▸ Virtual DOM ▸ Somente JavaScript
“ Don’t Rewrite, React! - Ryan Florence
? Perguntas? Talysson @talyssonoc talyssonoc.github.io
Obrigado! Talysson @talyssonoc talyssonoc.github.io