SlideShare une entreprise Scribd logo
1  sur  57
Télécharger pour lire hors ligne
The exciting future of…
React
React 16
Angular 1 👉 Angular 2 👉 JustAngular™
v0.14 👉 v15
React Fiber - THE CORE REACT
ALGORITHM HAS
BEEN COMPLETELY
REWRITTEN!!! 🔥 🔥 🔥
Error boundaries
Rendering multiple elements
without a wrapper
Portals
Custom dom attributes
Render only a string
Improved server-side rendering
Fiber, whatever
¯_(ツ)_/¯
Rendering multiple elements
without a wrapper 😍
Other things
Rendering multiple elements
without a wrapper
Understand how JSX compilation works
Nope #1
Nope #2
const ListItems = () => {
return <li> hello </li>
return <li> world </li>
}
Nope #3
const ListItems = () => {
return <div>
<li> hello </li>
<li> world </li>
</div>
}
const ListItems = () => {
return [
<li> hello </li>,
<li> world </li>,
<li> how are ya </li>
]
}
Yup, but ugly
const Aux = ({children}) => children;
Ofc people wrote this
Usage
const ListItems = () => {
return <Aux>
<li> hello </li>
<li> world </li>
<li> how are ya </li>
</Aux>
}
Verified live footage of the React
team after seeing the Aux component
import {Fragment} from ‘react’;
Fragments
const ListItem = () => {
return <Fragment>
<li> hello </li>
<li> world </li>
<li> how are ya </li>
</Fragment>
}
JSX Fragment syntax
const MultipleThings = () => {
return <>
<li> hello </li>
<li> world </li>
<li> how are ya </li>
</>
}
(a.k.a why people switch to Vue)
Use cases
const pairs = [
['React', 'Vue'],
['Redux', 'MobX'],
['jQuery', 'MooTools'],
['Sass', 'Less'],
['Hillary', 'Trump']
];
const MyList = () => {
return <ul>
{pairs.map(([first, second]) => <Fragment>
<li>{first} </li>
<li>{second} </li>
</Fragment>)}
</ul>
}
Use cases
const celebrities = ['Trump', 'Jake Paul', 'Justin
Timberlake', 'Dan Abramov', 'Me'];
const CelebritiesList = () => {
return <div>
{celebrities.map((celebrity, index) => <Fragment>
<div> {celebrity} </div>
{index !== celebrities.length - 1 && <hr />}
</Fragment>}
</div>
}
A component that renders a string
const ConvertTextToEmoji = ({children}) => {
//insert text-to-emoji algorithm here
return 'The world has enough emoji already.'
}
<ConvertTextToEmoji>
This text should be converted to emoji.
</ConvertTextToEmoji>
Portals
Provide a first-class way to render
children into a DOM node that exists
outside the DOM hierarchy of the
parent component.
Me reading about Portals
Portals
//index.html
<div>
<div id="root"> </div>
<div id="modal"> </div>
</div>
const Modal = ({children}) => {
return ReactDOM.createPortal(
children,
document.getElementById('modal')
);
};
class AboutPage extends Component {
state = {modalOpened: true}
toggleModal = () => this.setState({
modalOpened: !this.state.modalOpened
})
render() {
return (
<div>
<h1>About Us </h1>
<button onClick={this.toggleModal}>
toggle modal
</button>
{this.state.modalOpened && <Modal>
Content inside of modal
</Modal>}
</div>
);
}
}
How far is too far?
Demo time 🤓
Thinking of practical use-cases of Portals
Error boundaries
Handling JavaScript errors in components
Method #1
Don’t have any errors in
your components
Method #2
Don’t open the console, and
you won’t see any errors
Method #3
componentDidCatch
componentDidCatch
• If a class component defines this method,
it becomes an error boundary.
• Error boundaries only catch errors in the
components below them in the tree.
• An error boundary can’t catch an error
within itself.
class ErrorBoundary extends React.Component {
state = { hasError: false }
componentDidCatch(error, info) {
this.setState({ hasError: true });
logErrorToMyService(error, info);
}
render() {
if (this.state.hasError) {
return <h1>Something went wrong. </h1>;
}
return this.props.children;
}
}
const App = () => (
<div>
<h1> This is our app </h1>
<ErrorBoundary>
<GalleryWidget />
</ErrorBoundary>
</div>
);
Wrap the entire app in
<ErrorBoundary/>
React Fiber
Fiber = fast
TL;DR
Not Fiber = slow
React Fiber
It is responsible for most of the new features in
React 16, like error boundaries and fragments.
Async rendering - apps are more responsive
because React avoids blocking the main
thread.
createRef
(isn't meant to replace callback refs)
class MyComponent extends Component {
divRef = React.createRef();
render() {
return (
<div>
<input type="text" ref={this.divRef} />
</div>
);
}
componentDidMount() {
this.divRef.value.focus();
}
}
New Context API 🎉 🎉 🎉 🎉
2018 is gonna be
remembered for 2 things
Tide Pods & Context
Demo time 🤓
getDerivedStateFromProps
getPropsAndUpdateTheStateOn
EveryUpdateOfTheProps
getDerivedStateFromProps
• A static method
• Exists on the class, not on the instance
• Updates state based on change of props
getDerivedStateFromProps
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.currentRow === prevState.lastRow) {
return null;
}
const isScrolling = nextProps.currentRow > prevState.lastRow;
return {
lastRow: nextProps.currentRow,
isScrollingDown: isScrolling
};
}
Will be deprecated in React 16.4
☠ componentWillMount
☠ componentWillUpdate
☠ componentWillReceiveProps
MAYBE in React 16.4
😱 New component API (no
classes)
(take with a grain of salt)
IT’S STABLE ENOUGH FOR PRODUCTION
ALSO PLS SHOW A DEMO OF IT
AT CONFERENCES 😍
react-call-return
import {
unstable_createCall, unstable_createReturn
} from 'react-call-return';
Make it stable
import {
unstable_createCall as createCall,
unstable_createReturn as createReturn
} from 'react-call-return';
Demo time 🤓
✅ kitze.io
😞 @thekitze on Twitter
✅ @kitze on GitHub
✅ @kitze on Medium
Please ask me anything except:
- What font is that?
- What font size is that?
- What editor is that?
- What theme do you use?
☢
Bedankt en tot ziens 🙏
@thekitze
reactacademy.io
@kitze
@kitze

Contenu connexe

Tendances

Using Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databasesUsing Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databases
Raimonds Simanovskis
 

Tendances (20)

Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentation
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Domain Driven Design and Hexagonal Architecture with Rails
Domain Driven Design and Hexagonal Architecture with RailsDomain Driven Design and Hexagonal Architecture with Rails
Domain Driven Design and Hexagonal Architecture with Rails
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and Reconciliation
 
ReactJS
ReactJSReactJS
ReactJS
 
Practical JavaScript Promises
Practical JavaScript PromisesPractical JavaScript Promises
Practical JavaScript Promises
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React Native
 
Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast dive
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Promises, Promises
Promises, PromisesPromises, Promises
Promises, Promises
 
Promise pattern
Promise patternPromise pattern
Promise pattern
 
React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Databricks spark-knowledge-base-1
Databricks spark-knowledge-base-1Databricks spark-knowledge-base-1
Databricks spark-knowledge-base-1
 
G pars
G parsG pars
G pars
 
Using Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databasesUsing Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databases
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 

Similaire à The Exciting Future Of React

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
 

Similaire à The Exciting Future Of React (20)

React/Redux
React/ReduxReact/Redux
React/Redux
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - React
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
 
ReactJS
ReactJSReactJS
ReactJS
 
Lec7Handout.ppt
Lec7Handout.pptLec7Handout.ppt
Lec7Handout.ppt
 
A full introductory guide to React
A full introductory guide to ReactA full introductory guide to React
A full introductory guide to React
 
React - An Introduction
React - An IntroductionReact - An Introduction
React - An Introduction
 
ReactJS.ppt
ReactJS.pptReactJS.ppt
ReactJS.ppt
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 
ReactJS (1)
ReactJS (1)ReactJS (1)
ReactJS (1)
 
React js
React jsReact js
React js
 
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 lecture
React lectureReact lecture
React lecture
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
React & Redux in Hulu
React & Redux in HuluReact & Redux in Hulu
React & Redux in Hulu
 
React js
React jsReact js
React js
 
Getting Started with React v16
Getting Started with React v16Getting Started with React v16
Getting Started with React v16
 

Dernier

Dernier (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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?
 
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...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

The Exciting Future Of React