SlideShare une entreprise Scribd logo
1  sur  40
SIX MONTHS OF REACT & REDUX:
A REAL WORLD USE CASE
Thom Nichols - @thom_nic
DISCLAIMER:
 Not an expert
 I might be doing it wrong
SO YOU WANT TO TRY REACT +
REDUX…
WHAT ARE YOU (PROBABLY) GOING TO
NEED?
 Webpack
 Babel + presets
 React-redux
 Redux-thunk
 Redux-logger
 Axios or fetch-polyfill
 Immutable.js
 React
 Redux
 Jest or Mocha + JSDOM or Karma + Phantomjs
 React-router
 React-router-redux
ALL YOU NEED IS A FEW PACKAGES
FROM NPM
GREAT! AM I READY TO START
PROGRAMMING NOW?
WHAT ARE YOU (PROBABLY) GOING TO
NEED?
 Webpack
 Babel + presets
 React-redux
 Redux-thunk
 Redux-logger
 Axios or fetch-polyfill
 Immutable.js
 React
 Redux
 Jest or Mocha + JSDOM or Karma + Phantomjs
 React-router
 React-router-redux
What we actually
care about
WHAT ARE YOU (PROBABLY) GOING TO
NEED?
 Webpack
 Babel + presets
 React-redux
 Redux-thunk
 Redux-logger
 Axios or fetch-polyfill
 Immutable.js
 React
 Redux
 Jest or Mocha + JSDOM or Karma + Phantomjs
 React-router
 React-router-redux
What we actually
care about
LET’S TALK ABOUT REDUX
FLUX ARCHITECTURE
FLUX ARCHITECTURE - SIMPLIFIED
SHOW ME THE CODE!
TRIVIAL ACTION EXAMPLE
store.dispatch( addTodo(‘call mom’) );
TRIVIAL REDUCER EXAMPLE
THINGS NOBODY TOLD ME ABOUT
REACT + REDUX
USE IMMUTABLE.JS RECORDS!
 Without Records:
 With Records:
USE IMMUTABLE.JS RECORDS!
WHAT SHOULD MY STORES HOLD?
WHAT DOES MY DATA LOOK LIKE?
MY STORES HOLD MAPS
STORES MAY LISTEN TO “OTHER”
ACTIONS
I’M IN UR COMPONENT…
CONNECTIN UR PROPS
ACTIONS + PROMISE CHAINING =
AWESOME
ACTIONS + PROMISE CHAINING =
AWESOME
WHAT’S ANNOYING?
 Component testing connected components is hard.
I rely (mostly) on functional testing
 Export both a connect()-ed and non-connected component
 See: Erik Ras’ “ducks”
WHAT’S ANNOYING?
 It’s difficult to call a method on a component wrapped as a high-order
component…
DON’T DO IT
 BUT: you probably shouldn’t be doing that anyway:
 pass data via callbacks passed from parent component.
 Or pass data via a redux action
LET’S RECAP
 Use ImmutableJS records for domain types in stores
 Use ImmutableJS Maps often for store data containers
 Use redux-thunk to make remote requests in actions
 Async action creators should always return a promise
 Reducer cases are not always 1-to-1 with actions
 Let me know if you’ve figured out the component testing issue with
connected components…
 HoC component wrapping cause some pain
 Webpack is really the most annoying part
MORE TRICKS
DEBOUNCE EXPENSIVE ACTIONS
 Some independent top-level components say what data they want to
fetch from `componentWillMount()`
 Debounce  a single remote request
CONSISTENTLY DISPATCH START & END
ACTIONS
 These are used for loading indicator & error messaging
BONUS: REDUX-FORM IS AWESOME
BONUS: REDUX-FORM IS AWESOME
DECIDE WHAT WORKS FOR YOU
Frameworks are less about prescribing “the
right way” and more about getting everyone
to do things the same way.
- @thom_nic
THANKS
ACTUALLY….
ASK ME ABOUT DIGITAL ELECTRICITY
MORE SLIDES
I DON’T NEED ANGULAR-RESOURCE
 This is actually (really) boilerplate. Replaced with this:
WHY I DON’T NEED ANGULAR-
RESOURCE
 … and http thunks of thunks:
A WORD TO THE WISE…
 Avoid temptation to do client-side data manipulation to attempt to
mirror server state.
 Better to always fetch from the server as the source of truth

Contenu connexe

Tendances

React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with ReduxVedran Blaženka
 
Getting started with Redux js
Getting started with Redux jsGetting started with Redux js
Getting started with Redux jsCitrix
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overviewAlex Bachuk
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingBinary Studio
 
Introduction to React & Redux
Introduction to React & ReduxIntroduction to React & Redux
Introduction to React & ReduxBoris Dinkevich
 
Redux training
Redux trainingRedux training
Redux trainingdasersoft
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max PetruckMaksym Petruk
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and ReduxAli Sa'o
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux IntroductionNikolaus Graf
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥Remo Jansen
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and ReduxGlib Kechyn
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developerSwitch to React.js from AngularJS developer
Switch to React.js from AngularJS developerEugene Zharkov
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and ReconciliationZhihao Li
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJSAll Things Open
 

Tendances (20)

React & Redux
React & ReduxReact & Redux
React & Redux
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
 
Getting started with Redux js
Getting started with Redux jsGetting started with Redux js
Getting started with Redux js
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
 
React, Flux and a little bit of Redux
React, Flux and a little bit of ReduxReact, Flux and a little bit of Redux
React, Flux and a little bit of Redux
 
Using redux
Using reduxUsing redux
Using redux
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
Introduction to React & Redux
Introduction to React & ReduxIntroduction to React & Redux
Introduction to React & Redux
 
Redux training
Redux trainingRedux training
Redux training
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max Petruck
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
 
React & redux
React & reduxReact & redux
React & redux
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 
Switch to React.js from AngularJS developer
Switch to React.js from AngularJS developerSwitch to React.js from AngularJS developer
Switch to React.js from AngularJS developer
 
React Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and Reconciliation
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
 

En vedette

Async Server Rendering in React+Redux at NYTimes (redux-taxi)
Async Server Rendering in React+Redux at NYTimes (redux-taxi)Async Server Rendering in React+Redux at NYTimes (redux-taxi)
Async Server Rendering in React+Redux at NYTimes (redux-taxi)Jeremy Gayed
 
Mongo for the Mission Critical Enterprise
Mongo for the Mission Critical EnterpriseMongo for the Mission Critical Enterprise
Mongo for the Mission Critical EnterpriseMongoDB
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Ben Lesh
 
RxJS + Redux + React = Amazing
RxJS + Redux + React = AmazingRxJS + Redux + React = Amazing
RxJS + Redux + React = AmazingJay Phelps
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015Ben Lesh
 

En vedette (6)

Async Server Rendering in React+Redux at NYTimes (redux-taxi)
Async Server Rendering in React+Redux at NYTimes (redux-taxi)Async Server Rendering in React+Redux at NYTimes (redux-taxi)
Async Server Rendering in React+Redux at NYTimes (redux-taxi)
 
Mongo for the Mission Critical Enterprise
Mongo for the Mission Critical EnterpriseMongo for the Mission Critical Enterprise
Mongo for the Mission Critical Enterprise
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
 
RxJS + Redux + React = Amazing
RxJS + Redux + React = AmazingRxJS + Redux + React = Amazing
RxJS + Redux + React = Amazing
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015
 
React js
React jsReact js
React js
 

Similaire à ProvJS: Six Months of ReactJS and Redux

The History of React-Hot-Loader
The History of React-Hot-LoaderThe History of React-Hot-Loader
The History of React-Hot-LoaderAnton Korzunov
 
Ultimate Survival - React-Native edition
Ultimate Survival - React-Native editionUltimate Survival - React-Native edition
Ultimate Survival - React-Native editionRichard Radics
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and ReduxBoris Dinkevich
 
Using Docker in the Real World
Using Docker in the Real WorldUsing Docker in the Real World
Using Docker in the Real WorldTim Haak
 
Create ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageCreate ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageAndrii Lundiak
 
A React Journey
A React JourneyA React Journey
A React JourneyLinkMe Srl
 
Ryan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodRyan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodFITC
 
Matheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux AppMatheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux AppReact Conf Brasil
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
 
A Practical Approach to React Native at All Things Open Conference
A Practical Approach to React Native at All Things Open ConferenceA Practical Approach to React Native at All Things Open Conference
A Practical Approach to React Native at All Things Open ConferenceTracy Lee
 
React gsg presentation with ryan jung & elias malik
React   gsg presentation with ryan jung & elias malikReact   gsg presentation with ryan jung & elias malik
React gsg presentation with ryan jung & elias malikLama K Banna
 
React js programming concept
React js programming conceptReact js programming concept
React js programming conceptTariqul islam
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Aura LA GDG - July 17-2017
Aura LA GDG - July 17-2017Aura LA GDG - July 17-2017
Aura LA GDG - July 17-2017Kristan Uccello
 
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)danwrong
 
Tipping the scale - Eyal Eizenberg - Wix
Tipping the scale - Eyal Eizenberg - WixTipping the scale - Eyal Eizenberg - Wix
Tipping the scale - Eyal Eizenberg - WixEyal Eizenberg
 

Similaire à ProvJS: Six Months of ReactJS and Redux (20)

The History of React-Hot-Loader
The History of React-Hot-LoaderThe History of React-Hot-Loader
The History of React-Hot-Loader
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Ultimate Survival - React-Native edition
Ultimate Survival - React-Native editionUltimate Survival - React-Native edition
Ultimate Survival - React-Native edition
 
Universal React apps in Next.js
Universal React apps in Next.jsUniversal React apps in Next.js
Universal React apps in Next.js
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
 
Using Docker in the Real World
Using Docker in the Real WorldUsing Docker in the Real World
Using Docker in the Real World
 
Create ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageCreate ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm package
 
A React Journey
A React JourneyA React Journey
A React Journey
 
Ryan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodRyan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was Good
 
Matheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux AppMatheus Marsiglio - Isomorphic React + Redux App
Matheus Marsiglio - Isomorphic React + Redux App
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Performance
PerformancePerformance
Performance
 
A Practical Approach to React Native at All Things Open Conference
A Practical Approach to React Native at All Things Open ConferenceA Practical Approach to React Native at All Things Open Conference
A Practical Approach to React Native at All Things Open Conference
 
Do you queue (updated)
Do you queue (updated)Do you queue (updated)
Do you queue (updated)
 
React gsg presentation with ryan jung & elias malik
React   gsg presentation with ryan jung & elias malikReact   gsg presentation with ryan jung & elias malik
React gsg presentation with ryan jung & elias malik
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Aura LA GDG - July 17-2017
Aura LA GDG - July 17-2017Aura LA GDG - July 17-2017
Aura LA GDG - July 17-2017
 
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
 
Tipping the scale - Eyal Eizenberg - Wix
Tipping the scale - Eyal Eizenberg - WixTipping the scale - Eyal Eizenberg - Wix
Tipping the scale - Eyal Eizenberg - Wix
 

Dernier

What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Dernier (20)

What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

ProvJS: Six Months of ReactJS and Redux

Notes de l'éditeur

  1. What I’m going to present seems to be working OK for me. It might not work for you. Try it yourself and decide.
  2. • How many people have written a simple redux app? • How many people have read some tutorials? So you’ve heard redux is pretty rad. Lots of people say it’s cool. Maybe you’ve used Angular or Ember or Backbone and Marionette. Well, react is like that, except….
  3. Also react-router and redux-simple-router. Also hot module reloading. And the source maps. Never forget the source maps. You might spend a week getting those two things working.
  4. So before you've started writing any code your package.json is going to look something like this!
  5. Let's backup for a second. What you *really* care about is actually a small number of packages. These are actually *really* simple to learn. You’ll spend 4 hours learning this, and two weeks getting the tooling to work.
  6. By the end, you’ll feel like this. So what I'm really saying is, copy someone else's boilerplate example.
  7. Let’s try to remember what we’re trying to achieve
  8. You might have seen this before. https://facebook.github.io/flux/docs/overview.html
  9. Gross oversimplification of redux. Or is it? The view executes actions via the dispatcher. Actions update the store (state) via reducers. The store updates the view via connect() to react props.
  10. This is what you see… Too simple. How do I make a server request?? Source: https://github.com/reactjs/redux/blob/master/examples/todomvc/actions/index.js
  11. The key is always return a new object when you manipulate the store. It lets redux optimize react render passes. Source: https://github.com/reactjs/redux/blob/master/examples/todomvc/reducers/todos.js
  12. Ok so that's what you (probably) already knew about redux.
  13. If you’re use Python’s record type or Ruby’s struct… it’s just like that. Easy peasy data classes. Immutability is pretty much essential for redux because of how it optimizes updates. Immutable.js is definitely cleaner than using Object.assign and spread/ rest to create new objects. (It’s also faster.)
  14. If you’re use Python’s record type or Ruby’s struct… it’s just like that. Easy peasy data classes. Immutability is pretty much essential for redux because of how it optimizes updates. Immutable.js is definitely cleaner than using Object.assign and spread/ rest to create new objects. (It’s also faster.)
  15. Should stores hold a single object? A list if it’s
  16. I’ve got a list of nested items on the left… So immediately I know I need stores to hold a sequence of items. But also I need to be able to determine relations between items. (Normalizr helps with this.) In addition to the same item appearing both in the list and the main section. Long term you might want something like an LRU to deal with paging and data bloat.
  17. I need to be able to determine relations between items. (Normalizr helps with this.) I decided stores should be maps of my domain models. They have child/parent ID references so you can lookup corresponding parent children in each store. Long term you might want something like an LRU to deal with paging and data bloat.
  18. The reason why actions are disconnected from reducers is because they are not always 1-to-1. On line 35 the transmitter (child) reducer is populating the store from children in a fetched parent object.
  19. Let's look at connecting your store to view components. The connect method of react-redux is awesome. • Components are completely unaware of redux. • Connect() wrapped components have stores (state) and actions injected into props. • This makes un-connected components easily testable. • If you've done Java/Spring this feels like dependency injection
  20. This is why you need redux-thunk. Basically to do anything async. IDK why it’s not part of redux or react-redux. When you execute your action, return the promise and you can do things like navigation, close a dialog, etc. when the action completes.
  21. On line 81 I’m calling an action then closing a dialog and navigating to a new page (line 83) when successful. I could also perform specific steps if the action failed (e.g. 409 conflict on the server) If you ask me this is more appropriate place to put this logic than e.g. by getting a result from a store.
  22. Components wrapped in connect() can’t be searched for by Component name in shallow render tests. :( Erik Ras proposes exposing both a connected and non-connected component. See: https://github.com/erikras/ducks-modular-redux But testing stores is trivial!!!
  23. The connect() method has a workaround: see the `withRef` option. https://github.com/reactjs/react-redux/blob/master/docs/api.md This is actually a perfect example of how react state “traps” the application state.
  24. Instead of calling a method to get or change a component’s state, consider passing it from child to parent via a callback, and/or changing by dispatching a redux action. • Benefit: any part of the view heirarchy can now manipulate that state. E.g. a root view closing all dialogs. • Line 23 is calling a redux action. • Line 29 is an example of calling `closeDialogAction` in a promise chain
  25. The connect() method has a workaround: see the `withRef` option. https://github.com/reactjs/react-redux/blob/master/docs/api.md
  26. Should stores hold a single object? A list if it’s
  27. Actions that might be required by multiple disconnected components (e.g. initial data on page load) can easily be debounced to multiple expensive requests.
  28. This is how I manage the loading state. actionStarted() dispatches a loading increment action dispatchActionComplete() and dispatchError() does a decrement.
  29. Redux form solves the problem of trapping current form value in state
  30. Code for validation is trivial
  31. Andrew did a great presentation last month about React.js and I don’t think he used any flux framework. It works! • The unidirectional data flow does great things by itself. • You can build the rest (remote calls + app state) without too much effort.
  32. I’m thinking about ordering some shirts on Teespring – who’s interested? :D The end.
  33. I work at VoltServer – we make some pretty cool power disitribution technology. Ask me about Digital Electricity. It’s pretty rad.
  34. Extra stuff if there are questions.
  35. Actions are simple… Really simple.
  36. Replaced standard fetch actions with thunks to create cookie-cutter actions.
  37. Actions that might be required by multiple disconnected components (e.g. initial data on page load) can easily be debounced to multiple expensive requests.