SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
Universal JavaScript - React
_AGENDA
_AGENDA
CZĘŚĆ 00 _INTRO
CZĘŚĆ 01 _CZYM JEST UNIVERSAL JAVASCRIPT
CZĘŚĆ 02 _UNIVERSAL JAVASCRIPT I REACT
CZĘŚĆ 03 _TRANSMIT
CZĘŚĆ 04 _REDUX
CZĘŚĆ 05 _ZAGROŻENIA I PROBLEMY
- Projekty dla międzynarodowych marek - innowacje, software, web apps
- Prawie 4 lata na rynku, 40 osób na pokładzie
- Zwycięzcy Hacksummit() Global Hackathon
_INTRO
CZYM JEST
UNIVERSAL
JAVASCRIPT?
_CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT
_UNIVERSAL SPA
_CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT
_ZALETY
_CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT
- Poprawa SEO w przypadku przeglądarek nie wspierających analizy JavaScript
(Yandex, Baidu, Bing, Yahoo)
- Przyśpieszenie czasu ładowania strony
- Zapobieganie FOUC (Flash of Unstyled Content)
_TECHNOLOGIE
_CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT
- React
- Transmit
- Redux
- Universal Angular 2
UNIVERSAL
JAVASCRIPT
I REACT
_WSPARCIE ZE STRONY REACT
_CZĘŚĆ 02: UNIVERSAL JAVASCRIPT I REACT
- Virtual DOM
- react-dom/server
- Reużywanie aplikacji
_RENDEROWANIE CLIENT-SIDE
_CZĘŚĆ 02: UNIVERSAL JAVASCRIPT I REACT
import ReactDOM from 'react-dom';
import App from './app';
const reactRoot = window.document.getElementById
('react-root');
ReactDOM.render(<App/>);
_RENDEROWANIE SERVER-SIDE
_CZĘŚĆ 02: UNIVERSAL JAVASCRIPT I REACT
import {Server} from 'hapi';
import ReactDOM from 'react-dom/server';
import App from './App';
const server = new Server();
server.connection({ host: 'localhost', port: '8080'});
server.ext('onPreResponse', (requst, reply) => {
reply(`<html>
<head></head>
<body>
<div id="react-root">${ReactDOM.renderToString(< App/>)}</div>
</body>
</html>`);
});
TRANSMIT
_TRANSMIT CONTAINER
_CZĘŚĆ 03: TRANSMIT
import Transmit from 'transmit';
import React, {Component} from 'react';
class App extends Component {
render() {
return <div>Hello {this.props.user}!</div>;
}
}
export default Transmit.createContainer (App, {
fragments: {
user: Promise.resolve('John Smith')
}
});
_TRANSMIT RENDER
_CZĘŚĆ 03: TRANSMIT
Transmit.render(<App/>);
Transmit.renderToString (<App/>);
REDUX
_FETCH COMPONENT DATA
_CZĘŚĆ 04: REDUX
function fetchComponentData(dispatch, components, params) {
const needs = components. reduce((prev, current) => {
return current ? (current. needs || []).concat(prev) : prev;
}, []);
const promises = needs.map(need => dispatch(need(params)));
return Promise.all(promises);
}
_PROMISE MIDDLEWARE
_CZĘŚĆ 04: REDUX
function promiseMiddleware() {
return next => action => {
const {promise, type, ...rest} = action;
if (!promise) return next(action);
const SUCCESS = type;
const REQUEST = type + '_REQUEST';
const FAILURE = type + '_FAILURE';
next({... rest, type: REQUEST});
return promise
.then(res => {next({... rest, res, type: SUCCESS}); return true;})
. catch(error => {next({... rest, error, type: FAILURE}); return false;});
};
}
_COMPONENT
_CZĘŚĆ 04: REDUX
class App extends Component {
render() {
return (
< div>Hello world!</ div>
);
}
static needs = [
someAction
];
}
_RENDEROWANIE SERVER-SIDE
_CZĘŚĆ 04: REDUX
import {Server} from 'hapi';
import ReactDOM from 'react-dom/server';
import App from './App';
import store from './store';
const server = new Server();
server.connection({ host: 'localhost', port: '8080'});
server.ext('onPreResponse', (requst, reply) => {
reply(`<html>
<head></head>
<body>
<div id="react-root">${ReactDOM.renderToString(< App/>)}</div>
</body>
<script>window.__INITIAL_STATE__ = ${JSON.stringify(store.getState())}
</script>
</html>`);
});
PROBLEMY I
ZAGROŻENIA
_ZAGROŻENIA I PROBLEMY
_CZĘŚĆ 05: ZAGROŻENIA I PROBLEMY
- Zwiększenie skomplikowania architektury aplikacji
- Brak window, document, etc. po stronie serwera aplikacji
- Trudniejsze debugowanie
- Niespójność wyrenderowanych aplikacji
_ZAGROŻENIA I PROBLEMY
_CZĘŚĆ 05: ZAGROŻENIA I PROBLEMY
PYTANIA?
DZIĘKUJĘ ZA UWAGĘ

Contenu connexe

Dernier

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 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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Dernier (20)

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 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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Universal JavaScript with React

  • 2. _AGENDA _AGENDA CZĘŚĆ 00 _INTRO CZĘŚĆ 01 _CZYM JEST UNIVERSAL JAVASCRIPT CZĘŚĆ 02 _UNIVERSAL JAVASCRIPT I REACT CZĘŚĆ 03 _TRANSMIT CZĘŚĆ 04 _REDUX CZĘŚĆ 05 _ZAGROŻENIA I PROBLEMY
  • 3. - Projekty dla międzynarodowych marek - innowacje, software, web apps - Prawie 4 lata na rynku, 40 osób na pokładzie - Zwycięzcy Hacksummit() Global Hackathon _INTRO
  • 5. _CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT
  • 6. _UNIVERSAL SPA _CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT
  • 7. _ZALETY _CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT - Poprawa SEO w przypadku przeglądarek nie wspierających analizy JavaScript (Yandex, Baidu, Bing, Yahoo) - Przyśpieszenie czasu ładowania strony - Zapobieganie FOUC (Flash of Unstyled Content)
  • 8. _TECHNOLOGIE _CZĘŚĆ 01: CZYM JEST UNIVERSAL JAVASCRIPT - React - Transmit - Redux - Universal Angular 2
  • 10. _WSPARCIE ZE STRONY REACT _CZĘŚĆ 02: UNIVERSAL JAVASCRIPT I REACT - Virtual DOM - react-dom/server - Reużywanie aplikacji
  • 11. _RENDEROWANIE CLIENT-SIDE _CZĘŚĆ 02: UNIVERSAL JAVASCRIPT I REACT import ReactDOM from 'react-dom'; import App from './app'; const reactRoot = window.document.getElementById ('react-root'); ReactDOM.render(<App/>);
  • 12. _RENDEROWANIE SERVER-SIDE _CZĘŚĆ 02: UNIVERSAL JAVASCRIPT I REACT import {Server} from 'hapi'; import ReactDOM from 'react-dom/server'; import App from './App'; const server = new Server(); server.connection({ host: 'localhost', port: '8080'}); server.ext('onPreResponse', (requst, reply) => { reply(`<html> <head></head> <body> <div id="react-root">${ReactDOM.renderToString(< App/>)}</div> </body> </html>`); });
  • 14. _TRANSMIT CONTAINER _CZĘŚĆ 03: TRANSMIT import Transmit from 'transmit'; import React, {Component} from 'react'; class App extends Component { render() { return <div>Hello {this.props.user}!</div>; } } export default Transmit.createContainer (App, { fragments: { user: Promise.resolve('John Smith') } });
  • 15. _TRANSMIT RENDER _CZĘŚĆ 03: TRANSMIT Transmit.render(<App/>); Transmit.renderToString (<App/>);
  • 16. REDUX
  • 17. _FETCH COMPONENT DATA _CZĘŚĆ 04: REDUX function fetchComponentData(dispatch, components, params) { const needs = components. reduce((prev, current) => { return current ? (current. needs || []).concat(prev) : prev; }, []); const promises = needs.map(need => dispatch(need(params))); return Promise.all(promises); }
  • 18. _PROMISE MIDDLEWARE _CZĘŚĆ 04: REDUX function promiseMiddleware() { return next => action => { const {promise, type, ...rest} = action; if (!promise) return next(action); const SUCCESS = type; const REQUEST = type + '_REQUEST'; const FAILURE = type + '_FAILURE'; next({... rest, type: REQUEST}); return promise .then(res => {next({... rest, res, type: SUCCESS}); return true;}) . catch(error => {next({... rest, error, type: FAILURE}); return false;}); }; }
  • 19. _COMPONENT _CZĘŚĆ 04: REDUX class App extends Component { render() { return ( < div>Hello world!</ div> ); } static needs = [ someAction ]; }
  • 20. _RENDEROWANIE SERVER-SIDE _CZĘŚĆ 04: REDUX import {Server} from 'hapi'; import ReactDOM from 'react-dom/server'; import App from './App'; import store from './store'; const server = new Server(); server.connection({ host: 'localhost', port: '8080'}); server.ext('onPreResponse', (requst, reply) => { reply(`<html> <head></head> <body> <div id="react-root">${ReactDOM.renderToString(< App/>)}</div> </body> <script>window.__INITIAL_STATE__ = ${JSON.stringify(store.getState())} </script> </html>`); });
  • 22. _ZAGROŻENIA I PROBLEMY _CZĘŚĆ 05: ZAGROŻENIA I PROBLEMY - Zwiększenie skomplikowania architektury aplikacji - Brak window, document, etc. po stronie serwera aplikacji - Trudniejsze debugowanie - Niespójność wyrenderowanych aplikacji
  • 23. _ZAGROŻENIA I PROBLEMY _CZĘŚĆ 05: ZAGROŻENIA I PROBLEMY