SlideShare a Scribd company logo
1 of 74
Download to read offline
~Scratching
React Fiber
R A P
H A M
O R I M
Raphael
Amorim
This guy seems like a nice person, but
he doesn’t. Seriously. He likes topics
related to JavaScript, Python, Clojure,
WebGL, Algorithms and sometimes force
some git push.


Working most part of his time in useless
globo.com •
js foundation/jQuery member •
Mozillian •
Metido a besta •
@raphamundi
This guy seems like a
he doesn’t. Seriously.
related to JavaScript,
WebGL, Algorithms and
some git push.


Working most part of h
open source projects.
some git push.


Working most part of his
open source projects.
talentos.globo.com
thumbor.org
tsuru.io
megadraft.io
clappr.io
thumbor.orgtsuru.io
megadraft.io
clappr.io
opensource.globo.com
1#
Fast
Introduction
4 years ago
2013
React.js
appeared
bringing...
2013
Virtual-dom’s diff algorithm
2013
Virtual-dom’s diff algorithm
Jun 6, 2014
Isomorphic Applications
&&
SSR
Virtual-dom’s diff algorithm
Jun 6, 2014
Isomorphic Applications
&&
SSR
Virtual-dom’s diff algorithm
2015
Isomorphic Applications
&&
SSR
Rise of React Native
2015
Ended up shining eyes

from various developers…
2015
Ended up shining eyes

from various developers…
React Fiber
public on July 2016
But before we talk about it.
But before we talk about it.
Let’s talk about JS engine behavior
A JavaScript engine is a program or interpreter which
executes JavaScript code *
A JavaScript engine is a program or interpreter which
executes JavaScript code *
* A JavaScript engine may be a traditional interpreter, or it may
utilize just-in-time compilation to bytecode in some manner.
Which it is also known to be single thread
<div class="animation">0</div>
<img src="http://media.giphy.com/media/jkSvCVEXWlOla/giphy.gif">
<script>
setTimeout(() => {
const animation1 = document.querySelector('.animation')
for (var i = 0; i < 30000; i++) {
animation1.innerHTML = i
}
}, 3000)
</script>
abc
Why it happens?
busy
Main thread
<div class="animation">0</div>
<img src="http://media.giphy.com/media/jkSvCVEXWlOla/giphy.gif"
alt="">
<script>
setTimeout(() => {
const animation1 = document.querySelector('.animation')
let i = 0
function stepByStep() {
animation1.innerHTML = (i += 1)
if (i < 30000) {
requestAnimationFrame(stepByStep)
}
}
stepByStep()
}, 3000)
</script>
ab
Ok, but how It works
in React?
Code
Code > React
Code > React > Main Thread
It'll be enough for now <3
2#
Reconciliation
ab
It's important to remember that the
reconciliation algorithm is an
implementation detail.
React could rerender the whole app on every
action, the end result would be the same.
3#
Fiber
Fiber is a fully rewritten based on
this algorithm.
A fiber represents a unit of work.
v = f(d)
4#
Render Behavior
React fits nicely to render data
structures.
eg. 

DOM Structures, WebGL scene graph...
However.
However. 

Not to animate anything at 40fps~60fps
Let’s try to animate a simple spin
effect on a component only using the
React lifecycle
Visibly you will see that React will
charge a performance cost per frame
rotated
To get higher levels of performance
for animation: 



Synchronize the DOM
Skip layout render process whenever
possible
To get higher levels of performance
for animation:



Synchronize the DOM
Skip layout render process whenever
possible
To get higher levels of performance
for animation: 



Synchronize the DOM
Skip layout render process whenever
possible
React Fiber promises solve it.
“ Incremental
rendering ”
Divides the rendering work into
smaller pieces and distributes between
multiple frames.
Stack
Stack
Synchronous and recursive
This makes it impossible to divide
these processes into pieces.
Besides having a heavy context to
reproduce
This makes it impossible to divide
these processes into pieces.
Besides having a heavy context to
reproduce.
Fiber
Fiber
Asynchronous reconciliation
Determining the priority of different
types of processes.
Allow pausing and stopping processes.
Determining the priority of different
types of processes.
Allow pausing and stopping processes.
Uses requestAnimationFrame and
requestIdleCallback APIs.
It is iterative, not recursive. 



Soon it will not "drop" frames, since
respect Layout and Paint processes.
It is iterative, not recursive. 



Soon it will not "drop" frames, since
respect Layout and Paint processes.
3#
Renderer
ab
ab
isfiberreadyyet.com
code.facebook.com/posts/1716776591680069/
react-16-a-look-inside-an-api-compatible-
rewrite-of-our-frontend-ui-library/
github.com/
raphamorim/

react-conf-brasil
HELP: react-tv
Thank
you!
QUESTIONS: @RAPHAMUNDI

More Related Content

What's hot

Reactive Programming
Reactive ProgrammingReactive Programming
Reactive Programming
Zhentian Wan
 

What's hot (20)

Serverless GraphQL for Product Developers
Serverless GraphQL for Product DevelopersServerless GraphQL for Product Developers
Serverless GraphQL for Product Developers
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
 
Scala on Rails #rakutentech
Scala on Rails #rakutentechScala on Rails #rakutentech
Scala on Rails #rakutentech
 
Beyond The Rails Way
Beyond The Rails WayBeyond The Rails Way
Beyond The Rails Way
 
RxJS - The Basics & The Future
RxJS - The Basics & The FutureRxJS - The Basics & The Future
RxJS - The Basics & The Future
 
Hands on react native
Hands on react nativeHands on react native
Hands on react native
 
Reactive Programming
Reactive ProgrammingReactive Programming
Reactive Programming
 
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
 
Angular Ivy- An Overview
Angular Ivy- An OverviewAngular Ivy- An Overview
Angular Ivy- An Overview
 
Redux and context api with react native app introduction, use cases, implemen...
Redux and context api with react native app introduction, use cases, implemen...Redux and context api with react native app introduction, use cases, implemen...
Redux and context api with react native app introduction, use cases, implemen...
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Gradle
GradleGradle
Gradle
 
Rails Concept
Rails ConceptRails Concept
Rails Concept
 
面向引擎——编写高效率JS
面向引擎——编写高效率JS面向引擎——编写高效率JS
面向引擎——编写高效率JS
 
Real-time GraphQL API with minimum coding and maximum benefit
 Real-time GraphQL API with minimum coding and maximum benefit Real-time GraphQL API with minimum coding and maximum benefit
Real-time GraphQL API with minimum coding and maximum benefit
 
ASP.NET Core Unit Testing
ASP.NET Core Unit TestingASP.NET Core Unit Testing
ASP.NET Core Unit Testing
 
How we built a job board in one week with JHipster
How we built a job board in one week with JHipsterHow we built a job board in one week with JHipster
How we built a job board in one week with JHipster
 
New in Spring Framework 5.0: Functional Web Framework
New in Spring Framework 5.0: Functional Web FrameworkNew in Spring Framework 5.0: Functional Web Framework
New in Spring Framework 5.0: Functional Web Framework
 
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless SummitBuild a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
 

Similar to Raphael Amorim - Scrating React Fiber

Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
Kevin Whinnery
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
Kevin Whinnery
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Kyle Drake
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
Spike Brehm
 

Similar to Raphael Amorim - Scrating React Fiber (20)

Introduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with ClojurescriptIntroduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with Clojurescript
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
Angular 2 vs React. What to chose in 2017?
Angular 2 vs React. What to chose in 2017?Angular 2 vs React. What to chose in 2017?
Angular 2 vs React. What to chose in 2017?
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
Daniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého SchizmaDaniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého Schizma
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Ruby codebases in an entropic universe
Ruby codebases in an entropic universeRuby codebases in an entropic universe
Ruby codebases in an entropic universe
 
Web application intro
Web application introWeb application intro
Web application intro
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 
Workshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General OverviewWorkshop Intro: FrontEnd General Overview
Workshop Intro: FrontEnd General Overview
 
Node.js Deeper Dive
Node.js Deeper DiveNode.js Deeper Dive
Node.js Deeper Dive
 
Ruby On Google App Engine 2nd Athens Ruby Me
Ruby On Google App Engine 2nd Athens Ruby MeRuby On Google App Engine 2nd Athens Ruby Me
Ruby On Google App Engine 2nd Athens Ruby Me
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 
Web application intro + a bit of ruby (revised)
Web application intro + a bit of ruby (revised)Web application intro + a bit of ruby (revised)
Web application intro + a bit of ruby (revised)
 
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
 
Ofir Dagan - (Don’t) Blame it on React Native - Codemotion Rome 2019
Ofir Dagan - (Don’t) Blame it on React Native - Codemotion Rome 2019Ofir Dagan - (Don’t) Blame it on React Native - Codemotion Rome 2019
Ofir Dagan - (Don’t) Blame it on React Native - Codemotion Rome 2019
 
Concurrecy in Ruby
Concurrecy in RubyConcurrecy in Ruby
Concurrecy in Ruby
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
 
React Django Presentation
React Django PresentationReact Django Presentation
React Django Presentation
 

More from React Conf Brasil

More from React Conf Brasil (8)

Sibelius Seraphini - Relay Modern
Sibelius Seraphini - Relay ModernSibelius Seraphini - Relay Modern
Sibelius Seraphini - Relay Modern
 
Matheus Lima - O que tem de funcional no React
Matheus Lima - O que tem de funcional no ReactMatheus Lima - O que tem de funcional no React
Matheus Lima - O que tem de funcional no React
 
Sebastian Ferrari - Why React is good for business
Sebastian Ferrari - Why React is good for businessSebastian Ferrari - Why React is good for business
Sebastian Ferrari - Why React is good for business
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
 
João Gonçalves - Show do Milhão PWA com React (Caso de Sucesso)
João Gonçalves - Show do Milhão PWA com React (Caso de Sucesso)João Gonçalves - Show do Milhão PWA com React (Caso de Sucesso)
João Gonçalves - Show do Milhão PWA com React (Caso de Sucesso)
 
Marcelo Camargo - Let's dive into Babel: how everything works
Marcelo Camargo - Let's dive into Babel: how everything worksMarcelo Camargo - Let's dive into Babel: how everything works
Marcelo Camargo - Let's dive into Babel: how everything works
 
Kete Rufino e Christiano Milfont - Transformando um front-end legado em uma R...
Kete Rufino e Christiano Milfont - Transformando um front-end legado em uma R...Kete Rufino e Christiano Milfont - Transformando um front-end legado em uma R...
Kete Rufino e Christiano Milfont - Transformando um front-end legado em uma R...
 
Fernando Daciuk - The magic world of tests with Jest
Fernando Daciuk - The magic world of tests with JestFernando Daciuk - The magic world of tests with Jest
Fernando Daciuk - The magic world of tests with Jest
 

Recently uploaded

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

Raphael Amorim - Scrating React Fiber