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
[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
100
[Tropical on Rails 2026] Privacy on Rails
talyssonoc
1
130
[Nerdearla Argentina 2025] LLMs as domain experts
talyssonoc
0
70
[TDC SP 2025] Então você quer ser um praticante de DDD
talyssonoc
0
88
[DDD Brasil] Então você quer ser um praticante de DDD
talyssonoc
0
60
[Rails World 2025 Lighting Talks] Where is it?! - Avoiding the XY Problem
talyssonoc
0
69
[TDC Floripa 2025] Abordagens funcionais efetivas em TypeScript com Effect-TS
talyssonoc
0
130
[TDC Floripa 2025] Modelagem de domínios como construção de teorias
talyssonoc
0
110
[Encontro GURU-SP e ELUG] Ruby on Fails - Tratamento de erros de maneira efetiva e com convenções do Rails
talyssonoc
0
70
Other Decks in Programming
See All in Programming
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
230
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
ソフトウェアラスタライザ
fadis
1
800
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.4k
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
450
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
5
1.3k
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
890
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
130
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
140
業務時間外もAIに働いてもらう話
colorful12
3
10k
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
270
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
470
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
470
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
730
Scaling GitHub
holman
464
140k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.7k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Agile that works and the tools we love
rasmusluckow
331
22k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
Music & Morning Musume
bryan
47
7.4k
What's in a price? How to price your products and services
michaelherold
247
13k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
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