Top Banner
i s o m o r p h i s m @mtmr0x
26

Matheus Marsiglio - Isomorphic React + Redux App

Jan 28, 2018

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Matheus Marsiglio - Isomorphic React + Redux App

i s o m o r p h i s m

@mtmr0x

Page 2: Matheus Marsiglio - Isomorphic React + Redux App

Motivation

Create a great experience for users exploring super powers from two worldswith an awesome challenge.

Page 3: Matheus Marsiglio - Isomorphic React + Redux App

Knowledge level

Medium to advanced Javascript knowledge and some relevant experience working with React and Redux

Page 4: Matheus Marsiglio - Isomorphic React + Redux App

But don’t run!

There are going to have some surprises!

Page 5: Matheus Marsiglio - Isomorphic React + Redux App

What

Concepts and core problems

Page 6: Matheus Marsiglio - Isomorphic React + Redux App

!What

We’re not going to talk about detailed problemsfor time issues :(

Page 7: Matheus Marsiglio - Isomorphic React + Redux App

Client side

Faster navigation Smarter data persistence

More control over user behavior Easier DOM manipulation

Server side

More control over loaded assets SEO super powers

client serverisomorphic code

Page 8: Matheus Marsiglio - Isomorphic React + Redux App

client & server

Faster navigation Smarter data persistence

More control over user behavior Easier DOM manipulation

More control over loaded assets SEO super powers

Page 9: Matheus Marsiglio - Isomorphic React + Redux App

Index.js

• SEO • Basic render in server side

• Isomorphic Fetch • SEO • PRELOADED_DATA • Folder tree with containers and components • Component abstraction layer for isomorphic fetch • Both sides fetch problem • Hot fetched data marker

Page 10: Matheus Marsiglio - Isomorphic React + Redux App

SEO

Page 11: Matheus Marsiglio - Isomorphic React + Redux App

Basic render in server side

Bring ReactDOMServer to your app ->Your component ->

Similar to ReactDOM.render()->

Page 12: Matheus Marsiglio - Isomorphic React + Redux App

Isomorphic fetch

Page 13: Matheus Marsiglio - Isomorphic React + Redux App

SEO

But we still have a SEO problem here

Page 14: Matheus Marsiglio - Isomorphic React + Redux App

PRELOADED_DATA | the store

Page 15: Matheus Marsiglio - Isomorphic React + Redux App

PRELOADED_DATA | the store

Page 16: Matheus Marsiglio - Isomorphic React + Redux App

Folder structure

src/ └── components/ └── Home/ └── index.js └── Login/ └── index.js

└── containers/ └── Home.js └── Login.js

Page 17: Matheus Marsiglio - Isomorphic React + Redux App

Folder structure

src/ └── components/ └── Home/ └── index.js └── Login/ └── index.js

└── containers/ └── Home.js └── Login.js └── ConnectApplication.js

Page 18: Matheus Marsiglio - Isomorphic React + Redux App

Component abstraction layer

containers/ConnectApplication.js containers/Home.js

Page 19: Matheus Marsiglio - Isomorphic React + Redux App

PRELOADED_DATA | the store

SALVAR PRELOADED_STATE NO DOM

Page 20: Matheus Marsiglio - Isomorphic React + Redux App

Both sides fetch issue

Server side

Fetches, renders, magics

React checks data-reactid and do nothing :)

Client Side Javascript is loaded

Javascript will be executed and all fetched data will be refetched

Client side

Page 21: Matheus Marsiglio - Isomorphic React + Redux App

Hot fetched data marker

The API call

Mark the response based on its origin ->

Page 22: Matheus Marsiglio - Isomorphic React + Redux App

Hot fetched data marker

Action

Some magic here ->

Page 23: Matheus Marsiglio - Isomorphic React + Redux App

Hot fetched data marker

The magic

Page 24: Matheus Marsiglio - Isomorphic React + Redux App

Summary

• Basic render in server side • SEO issues • PRELOADED_DATA • Folder tree with containers and components • Component abstraction layer for isomorphic fetch • Both sides fetch problem • Hot fetched data marker

Page 25: Matheus Marsiglio - Isomorphic React + Redux App

https://goo.gl/e29GST

Let’s build an isomorphic boilerplate

Page 26: Matheus Marsiglio - Isomorphic React + Redux App

Thank You

https://all/@mtmr0x

https://goo.gl/e29GST