SlideShare a Scribd company logo
1 of 57
Download to read offline
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

More Related Content

What's hot

Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with ReduxFITC
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentationnishasowdri
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
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 RailsDeclan Whelan
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and ReconciliationZhihao Li
 
Practical JavaScript Promises
Practical JavaScript PromisesPractical JavaScript Promises
Practical JavaScript PromisesAsa Kusuma
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React NativeSoftware Guru
 
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 diveepamspb
 
React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15Rob Gietema
 
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...Knoldus Inc.
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for KotlinTechMagic
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript PromisesTomasz Bak
 
Databricks spark-knowledge-base-1
Databricks spark-knowledge-base-1Databricks spark-knowledge-base-1
Databricks spark-knowledge-base-1Rahul Kumar
 
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 databasesRaimonds Simanovskis
 

What's hot (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
 

Similar to Rendering Multiple Elements in React Without Wrappers

Similar to Rendering Multiple Elements in React Without Wrappers (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
 

Recently uploaded

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Recently uploaded (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Rendering Multiple Elements in React Without Wrappers