Concurrent mode Prabashwara Seneviratne (bash) Before we start - - PowerPoint PPT Presentation

concurrent mode
SMART_READER_LITE
LIVE PREVIEW

Concurrent mode Prabashwara Seneviratne (bash) Before we start - - PowerPoint PPT Presentation

Building responsive web apps with Concurrent mode Prabashwara Seneviratne (bash) Before we start Disclaimers In a nutshell What is it? For react, this the ability to work on multiple state updates at the same time Incremental Adoption


slide-1
SLIDE 1

Concurrent mode

Building responsive web apps with Prabashwara Seneviratne (bash)

slide-2
SLIDE 2

Disclaimers

Before we start

slide-3
SLIDE 3

For react, this the ability to work on multiple state updates at the same time

What is it?

In a nutshell

slide-4
SLIDE 4

Adoption

Incremental

Legacy Mode Concurrent Mode

ReactDOM.render(<App />, rootNode) ReactDOM.createRoot(rootNode).render(<App />) Blocking Mode

ReactDOM.createRoot(rootNode).render(<App />)

slide-5
SLIDE 5

PackagePile

Introducing A JS framework aggregator to keep track of all the JS frameworks created everyday

slide-6
SLIDE 6

The waterfall

Problem #1

slide-7
SLIDE 7

In code

Problem #1 Detail page fetches its data first Then the cards will render and start fetching their data

slide-8
SLIDE 8

In action

Problem #1

slide-9
SLIDE 9

Lazy & Suspense

Previously on React 16.6 Split javascript code into multiple files so that only what is required by the client would be downloaded

slide-10
SLIDE 10

Suspense

Coming up: the all new, fully extended Components can use special loaders which will start running straightaway, regardless of the structure

slide-11
SLIDE 11

In action

The new suspense

slide-12
SLIDE 12

Ideal solution

The

slide-13
SLIDE 13

The jump

Problem #2 The app changes state instantly - which leads to an ugly loading spinner while next data loads

slide-14
SLIDE 14

useTransition

The new solution useTransition lets you show the current state while react works on the next one in the background

slide-15
SLIDE 15

In action

withTransition

slide-16
SLIDE 16

Bad news

Time for The “unsafe” lifecycle methods are really unsafe now Old context API, string refs and findDOMNode are dead ReactDOM.findDOMNode(component)

slide-17
SLIDE 17

That’s it

bash2/package-pile me@bash.lk @MewsDevs https://developers.mews.com