SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
React custom renderers
Sviluppare applicazioni client, server e mobile con React 1
Jiayi Hu
Front-end developer & consultant
— https://github.com/jiayihu
— https://twitter.com/jiayi_ghu
— jiayi.ghu@gmail.com
Sviluppare applicazioni client, server e mobile con React 2
Some history !
Sviluppare applicazioni client, server e mobile con React 3
May 2013 - React is open-sourced 1
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
var Greeting = React.createReactClass({
render: function() {
return <h1>Hello, {this.props.name}</h1>;
}
});
ReactDOM.render(<Greeting name="Pordenone"></Greeting>, document.querySelector('.root'));
1
React: Rethinking best practices
Sviluppare applicazioni client, server e mobile con React 4
March 2015 - React Native is open-sourced
import React, { Component } from 'react';
import { AppRegistry, Text } from 'react-native';
export default class HelloWorldApp extends Component {
render() {
return (
<Text>Hello World!</Text>
);
}
}
AppRegistry.registerComponent('HelloWorldApp', () => HelloWorldApp);
Sviluppare applicazioni client, server e mobile con React 5
Oct 2016 - React VR is announced
import React from 'react';
import { AppRegistry, asset, Pano, Text, View } from 'react-vr';
class WelcomeToVR extends React.Component {
render() {
return (
<View>
<Pano source={asset('chess-world.jpg')}/>
<Text>hello</Text>
</View>
);
}
};
AppRegistry.registerComponent('WelcomeToVR', () => WelcomeToVR);
Sviluppare applicazioni client, server e mobile con React 6
April 2017
React Fiber is announced fiber
fiber
Lin Clark - A Cartoon Intro to Fiber
Sviluppare applicazioni client, server e mobile con React 7
8
Nov 2017
React custom renderers in Pordenone
Sviluppare applicazioni client, server e mobile con React 9
10
ReactSpeech
import React from 'react';
import { ReactSpeech } from './renderer/speech-renderer';
ReactSpeech.render([
<alice key={1}>Ciao Pordenone</alice>,
<luca key={2}>Benvenuti al mio talk di React</luca>,
]);
Sviluppare applicazioni client, server e mobile con React 11
12
Terminology
1. React Component
2. React Element
3. ReactFiber Instance
Sviluppare applicazioni client, server e mobile con React 13
React Component
class Greeting extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
Sviluppare applicazioni client, server e mobile con React 14
React Element
const element = <h1>Hello, world</h1>;
// Compiled
const element = React.createElement(
'h1',
{},
['Hello world']
);
Sviluppare applicazioni client, server e mobile con React 15
ReactFiber Instance
createInstance(type, props) {
const instance = document.createElement('h1');
instance.textContent = 'Hello world';
return instance;
},
Sviluppare applicazioni client, server e mobile con React 16
Pre-React 16 Fiber
import ReactInjection from 'react/lib/ReactInjection';
function inject() {
ReactInjection.NativeComponent.injectGenericComponentClass(
MyCustomComponentClass
);
}
Sviluppare applicazioni client, server e mobile con React 17
Post-React 16 Fiber
import Reconciler from 'react-reconciler';
const MyRenderer = Reconciler(HostConfig);
Sviluppare applicazioni client, server e mobile con React 18
Warning! Unstable API
react-reconciler@0.6.0
Sviluppare applicazioni client, server e mobile con React 19
20
21
Create instance
createInstance(type, props, internalInstanceHandle) {
return document.createElement(type);
// Do something with the props
}
createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
return text;
}
Sviluppare applicazioni client, server e mobile con React 22
Scheduling
{
now: ReactDOMFrameScheduling.now,
useSyncScheduling: true,
...
}
Sviluppare applicazioni client, server e mobile con React 23
Mutation
mutation: {
appendChild(parentInstance, child) {},
appendChildToContainer(parentInstance, child) {},
removeChild(parentInstance, child) {},
removeChildFromContainer(parentInstance, child) {},
insertBefore(parentInstance, child, beforeChild) {},
commitUpdate(instance, updatePayload, type, oldProps, newProps) {},
commitMount(instance, type, newProps) {},
commitTextUpdate(textInstance, oldText, newText) {},
},
Sviluppare applicazioni client, server e mobile con React 24
ReactSpeech
import Reconciler from 'react-reconciler';
const SpeechRenderer = Reconciler(HostConfig);
export const ReactSpeech = {
render(element, callback) {
const root = SpeechRenderer.createContainer({});
SpeechRenderer.updateContainer(element, root, null, callback);
},
};
Sviluppare applicazioni client, server e mobile con React 25
Usage
import React from 'react';
import { ReactSpeech } from './renderer/speech-renderer';
ReactSpeech.render([
<alice key={1}>Ciao Pordenone</alice>,
<luca key={2}>Benvenuti al mio talk di React</luca>,
]);
Sviluppare applicazioni client, server e mobile con React 26
Awesome custom renderers
— react-sketchapp
— react-pdf & react-redocx
— Ink
— react-tv
— react-hardware
Sviluppare applicazioni client, server e mobile con React 27
For dauntless people
Fevr 29 Nov presso AQuest: Can't live if livin' is
without rendering
Sviluppare applicazioni client, server e mobile con React 28
Resources
— ReactSpeech: github.com/jiayihu/experiments
— Slides: N/A
Sviluppare applicazioni client, server e mobile con React 29

Mais conteúdo relacionado

Mais procurados

React js t4 - components
React js   t4 - componentsReact js   t4 - components
React js t4 - componentsJainul Musani
 
Some experiences building an Android app with React Native & Redux
Some experiences building an Android app with React Native & ReduxSome experiences building an Android app with React Native & Redux
Some experiences building an Android app with React Native & ReduxAlex Bepple
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next FrameworkCommit University
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6William Marques
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSAdroitLogic
 
RESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTRESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTYakov Fain
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsLoiane Groner
 
Extending Kubernetes with Operators
Extending Kubernetes with OperatorsExtending Kubernetes with Operators
Extending Kubernetes with Operatorspeychevi
 
20190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.120190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.1Hui Seo
 
Introduction to React Hooks
Introduction to React HooksIntroduction to React Hooks
Introduction to React HooksFelicia O'Garro
 
Modern web app with REACT
Modern web app with REACTModern web app with REACT
Modern web app with REACTAndryRajohnson
 
React js t7 - forms-events
React js   t7 - forms-eventsReact js   t7 - forms-events
React js t7 - forms-eventsJainul Musani
 
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018Matt Raible
 
Angular 2... so can I use it now??
Angular 2... so can I use it now??Angular 2... so can I use it now??
Angular 2... so can I use it now??Laurent Duveau
 
Get rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesGet rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesMarios Fakiolas
 

Mais procurados (20)

React js t4 - components
React js   t4 - componentsReact js   t4 - components
React js t4 - components
 
Some experiences building an Android app with React Native & Redux
Some experiences building an Android app with React Native & ReduxSome experiences building an Android app with React Native & Redux
Some experiences building an Android app with React Native & Redux
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next Framework
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
 
Angular 2
Angular 2Angular 2
Angular 2
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
RESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTRESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoT
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Extending Kubernetes with Operators
Extending Kubernetes with OperatorsExtending Kubernetes with Operators
Extending Kubernetes with Operators
 
20190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.120190619 meetup r_shiny_reactlog_v0.1
20190619 meetup r_shiny_reactlog_v0.1
 
React js t3 - es6
React js   t3 - es6React js   t3 - es6
React js t3 - es6
 
Introduction to React Hooks
Introduction to React HooksIntroduction to React Hooks
Introduction to React Hooks
 
Modern web app with REACT
Modern web app with REACTModern web app with REACT
Modern web app with REACT
 
React js t7 - forms-events
React js   t7 - forms-eventsReact js   t7 - forms-events
React js t7 - forms-events
 
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
 
Angular 2... so can I use it now??
Angular 2... so can I use it now??Angular 2... so can I use it now??
Angular 2... so can I use it now??
 
React 101
React 101React 101
React 101
 
React js t5 - state
React js   t5 - stateReact js   t5 - state
React js t5 - state
 
Get rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesGet rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directives
 

Semelhante a React custom renderers

How to create components in react js
How to create components in react jsHow to create components in react js
How to create components in react jsBOSC Tech Labs
 
How To Integrate Native Android App With React Native.
How To Integrate Native Android App With React Native.How To Integrate Native Android App With React Native.
How To Integrate Native Android App With React Native.Techugo
 
Build web apps with react js
Build web apps with react jsBuild web apps with react js
Build web apps with react jsdhanushkacnd
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsMatteo Manchi
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend DevelopersSergio Nakamura
 
what is context API and How it works in React.pptx
what is context API and How it works in React.pptxwhat is context API and How it works in React.pptx
what is context API and How it works in React.pptxBOSC Tech Labs
 
How To Utilize Context API With Class And Functional Componen in React.pptx
How To Utilize Context API With Class And Functional Componen in React.pptxHow To Utilize Context API With Class And Functional Componen in React.pptx
How To Utilize Context API With Class And Functional Componen in React.pptxBOSC Tech Labs
 
How To Upgrade The React 18 Release Candidate.pptx
How To Upgrade The React 18 Release Candidate.pptxHow To Upgrade The React 18 Release Candidate.pptx
How To Upgrade The React 18 Release Candidate.pptxBOSC Tech Labs
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryjanet736113
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Ontico
 
React Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptxReact Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptxBOSC Tech Labs
 
Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for androidInnovationM
 
Retrofit Library In Android
Retrofit Library In AndroidRetrofit Library In Android
Retrofit Library In AndroidInnovationM
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and SymfonyIgnacio Martín
 

Semelhante a React custom renderers (20)

How to create components in react js
How to create components in react jsHow to create components in react js
How to create components in react js
 
Redux Universal
Redux UniversalRedux Universal
Redux Universal
 
How To Integrate Native Android App With React Native.
How To Integrate Native Android App With React Native.How To Integrate Native Android App With React Native.
How To Integrate Native Android App With React Native.
 
Build web apps with react js
Build web apps with react jsBuild web apps with react js
Build web apps with react js
 
Simple React Todo List
Simple React Todo ListSimple React Todo List
Simple React Todo List
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
 
what is context API and How it works in React.pptx
what is context API and How it works in React.pptxwhat is context API and How it works in React.pptx
what is context API and How it works in React.pptx
 
How To Utilize Context API With Class And Functional Componen in React.pptx
How To Utilize Context API With Class And Functional Componen in React.pptxHow To Utilize Context API With Class And Functional Componen in React.pptx
How To Utilize Context API With Class And Functional Componen in React.pptx
 
How To Upgrade The React 18 Release Candidate.pptx
How To Upgrade The React 18 Release Candidate.pptxHow To Upgrade The React 18 Release Candidate.pptx
How To Upgrade The React 18 Release Candidate.pptx
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
Intro react js
Intro react jsIntro react js
Intro react js
 
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
 
React Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptxReact Hooks Best Practices in 2022.pptx
React Hooks Best Practices in 2022.pptx
 
Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for android
 
Retrofit Library In Android
Retrofit Library In AndroidRetrofit Library In Android
Retrofit Library In Android
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 

Último

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...Miguel Araújo
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

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...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

React custom renderers

  • 1. React custom renderers Sviluppare applicazioni client, server e mobile con React 1
  • 2. Jiayi Hu Front-end developer & consultant — https://github.com/jiayihu — https://twitter.com/jiayi_ghu — jiayi.ghu@gmail.com Sviluppare applicazioni client, server e mobile con React 2
  • 3. Some history ! Sviluppare applicazioni client, server e mobile con React 3
  • 4. May 2013 - React is open-sourced 1 import React, { Component } from 'react'; import ReactDOM from 'react-dom'; var Greeting = React.createReactClass({ render: function() { return <h1>Hello, {this.props.name}</h1>; } }); ReactDOM.render(<Greeting name="Pordenone"></Greeting>, document.querySelector('.root')); 1 React: Rethinking best practices Sviluppare applicazioni client, server e mobile con React 4
  • 5. March 2015 - React Native is open-sourced import React, { Component } from 'react'; import { AppRegistry, Text } from 'react-native'; export default class HelloWorldApp extends Component { render() { return ( <Text>Hello World!</Text> ); } } AppRegistry.registerComponent('HelloWorldApp', () => HelloWorldApp); Sviluppare applicazioni client, server e mobile con React 5
  • 6. Oct 2016 - React VR is announced import React from 'react'; import { AppRegistry, asset, Pano, Text, View } from 'react-vr'; class WelcomeToVR extends React.Component { render() { return ( <View> <Pano source={asset('chess-world.jpg')}/> <Text>hello</Text> </View> ); } }; AppRegistry.registerComponent('WelcomeToVR', () => WelcomeToVR); Sviluppare applicazioni client, server e mobile con React 6
  • 7. April 2017 React Fiber is announced fiber fiber Lin Clark - A Cartoon Intro to Fiber Sviluppare applicazioni client, server e mobile con React 7
  • 8. 8
  • 9. Nov 2017 React custom renderers in Pordenone Sviluppare applicazioni client, server e mobile con React 9
  • 10. 10
  • 11. ReactSpeech import React from 'react'; import { ReactSpeech } from './renderer/speech-renderer'; ReactSpeech.render([ <alice key={1}>Ciao Pordenone</alice>, <luca key={2}>Benvenuti al mio talk di React</luca>, ]); Sviluppare applicazioni client, server e mobile con React 11
  • 12. 12
  • 13. Terminology 1. React Component 2. React Element 3. ReactFiber Instance Sviluppare applicazioni client, server e mobile con React 13
  • 14. React Component class Greeting extends React.Component { render() { return <h1>Hello, {this.props.name}</h1>; } } Sviluppare applicazioni client, server e mobile con React 14
  • 15. React Element const element = <h1>Hello, world</h1>; // Compiled const element = React.createElement( 'h1', {}, ['Hello world'] ); Sviluppare applicazioni client, server e mobile con React 15
  • 16. ReactFiber Instance createInstance(type, props) { const instance = document.createElement('h1'); instance.textContent = 'Hello world'; return instance; }, Sviluppare applicazioni client, server e mobile con React 16
  • 17. Pre-React 16 Fiber import ReactInjection from 'react/lib/ReactInjection'; function inject() { ReactInjection.NativeComponent.injectGenericComponentClass( MyCustomComponentClass ); } Sviluppare applicazioni client, server e mobile con React 17
  • 18. Post-React 16 Fiber import Reconciler from 'react-reconciler'; const MyRenderer = Reconciler(HostConfig); Sviluppare applicazioni client, server e mobile con React 18
  • 19. Warning! Unstable API react-reconciler@0.6.0 Sviluppare applicazioni client, server e mobile con React 19
  • 20. 20
  • 21. 21
  • 22. Create instance createInstance(type, props, internalInstanceHandle) { return document.createElement(type); // Do something with the props } createTextInstance(text, rootContainerInstance, internalInstanceHandle) { return text; } Sviluppare applicazioni client, server e mobile con React 22
  • 24. Mutation mutation: { appendChild(parentInstance, child) {}, appendChildToContainer(parentInstance, child) {}, removeChild(parentInstance, child) {}, removeChildFromContainer(parentInstance, child) {}, insertBefore(parentInstance, child, beforeChild) {}, commitUpdate(instance, updatePayload, type, oldProps, newProps) {}, commitMount(instance, type, newProps) {}, commitTextUpdate(textInstance, oldText, newText) {}, }, Sviluppare applicazioni client, server e mobile con React 24
  • 25. ReactSpeech import Reconciler from 'react-reconciler'; const SpeechRenderer = Reconciler(HostConfig); export const ReactSpeech = { render(element, callback) { const root = SpeechRenderer.createContainer({}); SpeechRenderer.updateContainer(element, root, null, callback); }, }; Sviluppare applicazioni client, server e mobile con React 25
  • 26. Usage import React from 'react'; import { ReactSpeech } from './renderer/speech-renderer'; ReactSpeech.render([ <alice key={1}>Ciao Pordenone</alice>, <luca key={2}>Benvenuti al mio talk di React</luca>, ]); Sviluppare applicazioni client, server e mobile con React 26
  • 27. Awesome custom renderers — react-sketchapp — react-pdf & react-redocx — Ink — react-tv — react-hardware Sviluppare applicazioni client, server e mobile con React 27
  • 28. For dauntless people Fevr 29 Nov presso AQuest: Can't live if livin' is without rendering Sviluppare applicazioni client, server e mobile con React 28
  • 29. Resources — ReactSpeech: github.com/jiayihu/experiments — Slides: N/A Sviluppare applicazioni client, server e mobile con React 29