SlideShare a Scribd company logo
1 of 31
Download to read offline
React+Redux
Workshops
Marcin Grzywaczewski (@Killavus)
Arkency
What
• An app for managing conferences
• Planning conferences
• Scheduling conference days
• Accepting events from CFP (call for papers)
• Scheduling events within conference days
How
• React.js and Redux will be used to create an
interface
• HTML Mockups are prepared so you can base on
it (I’ll be happy if you experiment with your own
solutions, though)
• Project with an API and all needed libraries is
provided
• One view = one React.js+Redux application
React.js
• Responsible for rendering HTML.
• A function which takes properties and returns HTML.
• You create components which are small pieces of your
interface and you compose them together.
• React.js uses JSX syntax, which is very similar to
HTML.
• There is a concept of state, but thanks to Redux it is
unnecessary.
Component as function
JSBin Code
Component as React class
JSBin Code
Composing components
How to make it dynamic?
• You can’t change props!
• You can call ReactDOM.render again. It is fast,
thanks to React.js internal algorithms.
• There is a concept of state, but we won’t use it
beacuse you don’t need it.
Dynamic component?
JSBin Code
What if…
• You can have some piece of data needed to
render a component.
• Every time a piece of data changes you re-
render your component. Your component is
notified somehow about the change.
• This is what Redux will provide to us.
Redux
• Manages the data flow in your application.
• You emit actions which are like parameters for Rails
update endpoint (but named!). Actions are created by
action creators.
• Actions modify state.
• State is stored within a store.
• How an action modifies state is determined by a
reducer.
Greeter with React+Redux
• A function is called an app when contains:
• React components
• Redux building blocks
• Let’s create a GreeterApp, step by step.
Empty App
Initial State
Action Creator
A return value of this function is called an action.
Reducer
Reducer recap
• A reducer is a function which takes the current
state and an action and returns the new state
based on an action processed.
• The return value must be a new object. No
mutated values allowed!
Wrongly written reducer
(mutation of state)
Store
You may consider store as a Redux internal thing.
All you need to do is to pass a reducer and initial state and
you are done.
Components
Components recap
• The new property will be passed -
nameChanged which is a function passed to
onChange of GreeterEdit.
• Components are blissfully unaware of being
managed by Redux ;).
• But how to connect React + Redux together?
Connecting React & Redux
• To connect React.js components with Redux stores
you need create a connector.
• Connector is a pair of state mapper and dispatch
mapper.
• State mapper takes your state and produces an object
which will be merged to component’s properties.
• Dispatch mapper exposes dispatch function which
passes actions to a store. It returns an object which
will get merged to component’s properties too.
Dispatch & State mappers
Notice how action creator is used to create an action emitted
to a store. It is not a coincidence!
connect function
• connect function takes your state mapper and
dispatch mapper and creates a connector. It is a
function.
• To make your component connected you just
pass a component as an argument to a
connector.
Connector & Connected
Component
Provider
• We know how to map state to properties and
we’re exposing functions for dispatching
actions. But we don’t know where to dispatch
our actions!
• There is a Provider component. You wrap your
connected component with it. It takes store as a
property.
Provider usage & return
value of the GreeterApp
GreeterApp Usage
GreeterApp Code
JSBin Code
Summary
• React.js is great for defining your user interface in
the declarative way.
• Redux is great for managing the data flow in a
simple way.
• You can connect the two together, removing the
problem of updating React components.
• Component’s built-in state is not needed. It is the
most troubling part of React components!
Good luck!

More Related Content

What's hot

What's hot (20)

React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
 
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 Lifecycle and Reconciliation
React Lifecycle and ReconciliationReact Lifecycle and Reconciliation
React Lifecycle and Reconciliation
 
How to Redux
How to ReduxHow to Redux
How to Redux
 
Angular redux
Angular reduxAngular redux
Angular redux
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
 
React & redux
React & reduxReact & redux
React & redux
 
Building Modern Web Applications using React and Redux
 Building Modern Web Applications using React and Redux Building Modern Web Applications using React and Redux
Building Modern Web Applications using React and Redux
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps.
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
 
Academy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & ToolingAcademy PRO: React JS. Redux & Tooling
Academy PRO: React JS. Redux & Tooling
 
Intro to ReactJS
Intro to ReactJSIntro to ReactJS
Intro to ReactJS
 
Introduction to react
Introduction to reactIntroduction to react
Introduction to react
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
Workshop 22: React-Redux Middleware
Workshop 22: React-Redux MiddlewareWorkshop 22: React-Redux Middleware
Workshop 22: React-Redux Middleware
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 

Viewers also liked (12)

React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
React & Redux
React & ReduxReact & Redux
React & Redux
 
AIA Studio 111 Folio
AIA Studio 111 FolioAIA Studio 111 Folio
AIA Studio 111 Folio
 
MSBI LIVE & VIDEO TRAINING From SQL-SCHOOL
MSBI LIVE & VIDEO TRAINING From SQL-SCHOOLMSBI LIVE & VIDEO TRAINING From SQL-SCHOOL
MSBI LIVE & VIDEO TRAINING From SQL-SCHOOL
 
Presentation5
Presentation5Presentation5
Presentation5
 
Ikf presentation
Ikf presentationIkf presentation
Ikf presentation
 
ScienceSoft: Open Software for Open Science
ScienceSoft: Open Software for Open ScienceScienceSoft: Open Software for Open Science
ScienceSoft: Open Software for Open Science
 
Presentation2
Presentation2Presentation2
Presentation2
 
Why would we want to talk to customers or them to us? TCUK 2012
Why would we want to talk to customers or them to us? TCUK 2012Why would we want to talk to customers or them to us? TCUK 2012
Why would we want to talk to customers or them to us? TCUK 2012
 
Mortal instruments program days rr
Mortal instruments program days rrMortal instruments program days rr
Mortal instruments program days rr
 
Presentation1
Presentation1Presentation1
Presentation1
 
Ke toan tai_chinh_02
Ke toan tai_chinh_02Ke toan tai_chinh_02
Ke toan tai_chinh_02
 

Similar to React.js+Redux Workshops

Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
Introduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptxIntroduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptx
SHAIKIRFAN715544
 

Similar to React.js+Redux Workshops (20)

React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Introduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic AppsIntroduction to React, Flux, and Isomorphic Apps
Introduction to React, Flux, and Isomorphic Apps
 
Getting started with react & redux
Getting started with react & reduxGetting started with react & redux
Getting started with react & redux
 
Spfx with react redux
Spfx with react reduxSpfx with react redux
Spfx with react redux
 
Reactjs
Reactjs Reactjs
Reactjs
 
Redux Like Us
Redux Like UsRedux Like Us
Redux Like Us
 
reactJS
reactJSreactJS
reactJS
 
An Overview of the React Ecosystem
An Overview of the React EcosystemAn Overview of the React Ecosystem
An Overview of the React Ecosystem
 
FRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptxFRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptx
 
downloads_introduction to redux.pptx
downloads_introduction to redux.pptxdownloads_introduction to redux.pptx
downloads_introduction to redux.pptx
 
React
ReactReact
React
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
 
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
 
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 and Flux life cycle with JSX, React Router and Jest Unit Testing
React and  Flux life cycle with JSX, React Router and Jest Unit TestingReact and  Flux life cycle with JSX, React Router and Jest Unit Testing
React and Flux life cycle with JSX, React Router and Jest Unit Testing
 
Introduction to React JS.pptx
Introduction to React JS.pptxIntroduction to React JS.pptx
Introduction to React JS.pptx
 
Introduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptxIntroduction to ReactJS UI Web Dev .pptx
Introduction to ReactJS UI Web Dev .pptx
 
Understanding Facebook's React.js
Understanding Facebook's React.jsUnderstanding Facebook's React.js
Understanding Facebook's React.js
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
vu2urc
 

Recently uploaded (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

React.js+Redux Workshops

  • 2. What • An app for managing conferences • Planning conferences • Scheduling conference days • Accepting events from CFP (call for papers) • Scheduling events within conference days
  • 3. How • React.js and Redux will be used to create an interface • HTML Mockups are prepared so you can base on it (I’ll be happy if you experiment with your own solutions, though) • Project with an API and all needed libraries is provided • One view = one React.js+Redux application
  • 4. React.js • Responsible for rendering HTML. • A function which takes properties and returns HTML. • You create components which are small pieces of your interface and you compose them together. • React.js uses JSX syntax, which is very similar to HTML. • There is a concept of state, but thanks to Redux it is unnecessary.
  • 6. Component as React class JSBin Code
  • 8. How to make it dynamic? • You can’t change props! • You can call ReactDOM.render again. It is fast, thanks to React.js internal algorithms. • There is a concept of state, but we won’t use it beacuse you don’t need it.
  • 10. What if… • You can have some piece of data needed to render a component. • Every time a piece of data changes you re- render your component. Your component is notified somehow about the change. • This is what Redux will provide to us.
  • 11. Redux • Manages the data flow in your application. • You emit actions which are like parameters for Rails update endpoint (but named!). Actions are created by action creators. • Actions modify state. • State is stored within a store. • How an action modifies state is determined by a reducer.
  • 12. Greeter with React+Redux • A function is called an app when contains: • React components • Redux building blocks • Let’s create a GreeterApp, step by step.
  • 15. Action Creator A return value of this function is called an action.
  • 17. Reducer recap • A reducer is a function which takes the current state and an action and returns the new state based on an action processed. • The return value must be a new object. No mutated values allowed!
  • 19. Store You may consider store as a Redux internal thing. All you need to do is to pass a reducer and initial state and you are done.
  • 21. Components recap • The new property will be passed - nameChanged which is a function passed to onChange of GreeterEdit. • Components are blissfully unaware of being managed by Redux ;). • But how to connect React + Redux together?
  • 22. Connecting React & Redux • To connect React.js components with Redux stores you need create a connector. • Connector is a pair of state mapper and dispatch mapper. • State mapper takes your state and produces an object which will be merged to component’s properties. • Dispatch mapper exposes dispatch function which passes actions to a store. It returns an object which will get merged to component’s properties too.
  • 23. Dispatch & State mappers Notice how action creator is used to create an action emitted to a store. It is not a coincidence!
  • 24. connect function • connect function takes your state mapper and dispatch mapper and creates a connector. It is a function. • To make your component connected you just pass a component as an argument to a connector.
  • 26. Provider • We know how to map state to properties and we’re exposing functions for dispatching actions. But we don’t know where to dispatch our actions! • There is a Provider component. You wrap your connected component with it. It takes store as a property.
  • 27. Provider usage & return value of the GreeterApp
  • 30. Summary • React.js is great for defining your user interface in the declarative way. • Redux is great for managing the data flow in a simple way. • You can connect the two together, removing the problem of updating React components. • Component’s built-in state is not needed. It is the most troubling part of React components!