SlideShare a Scribd company logo
1 of 30
Download to read offline
REACT
INTRODUCTION TO WITH
MOBX!
ABOUT AMBROSE
▸ Glad dad of 6 munchkins.
▸ Making pro software for ~18 years 

Computer geek since 1987
▸ Shipped over 45 projects, led over 20. 2 Patents. 

Sometime dev, arch, UX guy, manager, PM, etc.
▸ 8x Microsoft MVP; Books, Blogs…
▸ Gone Skinning Dipping in Bulgarian Mountain Hot Springs
INTRO TO REACT WITH MOBX
THE PLAN
▸ Why MobX?

In Which I Cover the Complete History of Functional State Management (j/k)
▸ Key Concepts

A Bit Mind-bending but Easy to Use
▸ With the Showing of Some Examples

Someone just told me these are the BEST examples!
INTRO TO REACT WITH MOBX
ABOUT YOU?
▸ Front End or Full Stack Dev
▸ Comfy with JavaScript,
ideally ES2015+.
▸ You went to my last session
or already are familiar with
React.
▸ You are not a MobX expert.
INTRO TO REACT WITH MOBX
WHY MOBX?
▸ It Just Feels Right
▸ Easy to Use*
▸ Less Trouble than setState
▸ Simpler/Less Dogmatic

then Redux
▸ Widely Used

https://github.com/mobxjs/awesome-mobx
INTRO TO REACT WITH MOBX
PREFACE: GETTING MOBX
▸ https://reactjs.org/ <- First Get React
▸ https://mobx.js.org/ - Then Get MobX



npm i mobx mobx-react —save
“UNIDIRECTIONAL DATA FLOW”
KEY CONCEPT #1
INTRO TO REACT WITH MOBX
COMPONENT COMMUNICATION
PROPS DOWN
EVENTS UP
INTRO TO REACT WITH MOBX
MOBX
PROPS DOWN
EVENTS UP
STATE ACTIONS
OBSERVABLE
KEY CONCEPT #2
INTRO TO REACT WITH MOBX
JUST ADD WATER!
▸ Add MobX to your project.
▸ Start decorating!
DECORATORS
KEY CONCEPT #2.5
INTRO TO REACT WITH MOBX
DECORATE YOUR CLASSES (FUNCTIONS) AND PROPERTIES
▸ Declarative way to augment your code. (Similar to .NET
Attributes)
▸ Syntax*: prefix thing:

@[decorator][(options)] [thing]
▸ Very common for MobX:
▸ @observable myProp;
▸ @observer class MyComponent {}
*Syntax is subject to change as this is a Stage 2 proposal.
INTRO TO REACT WITH MOBX
NB: USING DECORATORS WITH VS CODE
▸ Unless you like this:
▸ Add a tsconfig.json to your project root like this:
INTRO TO REACT WITH MOBX
BACK TO JUST ADDING WATER!
▸ Add MobX to your project.
▸ Start decorating!
DON’T FORGET ABOUT
@COMPUTED!
Ambrose
INTRO TO REACT WITH MOBX
INTRO TO REACT WITH MOBX
CAUTION: MOBX AND CREATE-REACT-APP
▸ CRA - Does not allow build config. Does not allow decorators (Stage 2).
▸ Option: Use without decorators

https://github.com/benawad/simple-mobx/tree/1_counter
▸ Option: Use npm run eject

https://swizec.com/blog/mobx-with-create-react-app/swizec/7158
▸ Option: Use custom-react-scripts

https://medium.com/@kitze/configure-create-react-app-without-ejecting-
d8450e96196a
▸ More on with/without decorators: https://mobx.js.org/best/decorators.html
INTRO TO REACT WITH MOBX
CONVERTING CREATE-REACT-APP
▸ yarn remove react-scripts && yarn add
custom-react-scripts
▸ Add .env file with REACT_APP_DECORATORS = true;
▸ npm i mobx mobx-react —save
OBSERVER
KEY CONCEPT #3
MODIFY THROUGH “ACTIONS”
KEY CONCEPT #4
THE “STORE”
KEY CONCEPT #5
STOOOOOOOORE…
https://mobx.js.org/best/store.html
OTHER “DERIVATIONS” AND GOODIES
KEY CONCEPT #6
More at: https://mobx.js.org/intro/concepts.html
INTRO TO REACT WITH MOBX
COMPUTED
ONE OF MY
OBSERVABLES
CHANGED
HEY, I PROBABLY
HAVE A NEW VALUE!
INTRO TO REACT WITH MOBX
REACTION
ONE OF MY
OBSERVABLES
CHANGED
Secret Agent Man
INTRO TO REACT WITH MOBX
OTHER GOODIES
https://mobx.js.org/refguide/api.html
Scroll down to Utilities
isArrayLike!
THERE BE DRAGONS
WARNING:
INTRO TO REACT WITH MOBX
THAT’S IT! YOU’VE SEEN…
▸ What MobX is All About
▸ Unidirectional Data Flow
▸ Decorators:
▸ @observable
▸ @observer
▸ @computed
▸ How to Get More Reactive
▸ Modifying State with
Actions
▸ Fancypants “Stores”
▸ Other Goodies
REPETITIO MATER STUDIORUM
EST.
Ancient Dude
INTRO TO REACT WITH MOBX
REPETITION IS THE MOTHER OF
ALL LEARNING.
Dude What Speaks Modern English
INTRO TO REACT WITH MOBX
Introduction to React with MobX

More Related Content

What's hot

[PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management
[PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management [PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management
[PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management
CheyenneWalls1
 
08 10 12 Meebo Ajaxworld Preso
08 10 12 Meebo Ajaxworld Preso08 10 12 Meebo Ajaxworld Preso
08 10 12 Meebo Ajaxworld Preso
rajivmordani
 

What's hot (10)

October 2014 UG Session Promo Slide Deck
October 2014 UG Session Promo Slide DeckOctober 2014 UG Session Promo Slide Deck
October 2014 UG Session Promo Slide Deck
 
Microcopy | An Easy to Use Guide
Microcopy | An Easy to Use Guide Microcopy | An Easy to Use Guide
Microcopy | An Easy to Use Guide
 
GNU Screen
GNU ScreenGNU Screen
GNU Screen
 
Overcoming Command Line Allergies
Overcoming Command Line AllergiesOvercoming Command Line Allergies
Overcoming Command Line Allergies
 
Flashmeeting / Chris Barker
Flashmeeting / Chris BarkerFlashmeeting / Chris Barker
Flashmeeting / Chris Barker
 
Magit
MagitMagit
Magit
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Have we forgotten how to program? - Tunisian WebDev MeetUp
Have we forgotten how to program? - Tunisian WebDev MeetUpHave we forgotten how to program? - Tunisian WebDev MeetUp
Have we forgotten how to program? - Tunisian WebDev MeetUp
 
[PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management
[PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management [PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management
[PDF] How to Become a Scrum Master in 7 Simple Steps Agile Project Management
 
08 10 12 Meebo Ajaxworld Preso
08 10 12 Meebo Ajaxworld Preso08 10 12 Meebo Ajaxworld Preso
08 10 12 Meebo Ajaxworld Preso
 

Similar to Introduction to React with MobX

Similar to Introduction to React with MobX (20)

BSides Iowa 2018: Windows COM: Red vs Blue
BSides Iowa 2018: Windows COM: Red vs BlueBSides Iowa 2018: Windows COM: Red vs Blue
BSides Iowa 2018: Windows COM: Red vs Blue
 
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP ModeEmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode
 
Real-World DevOps — 20 Practical Developers Tips for Tightening Your Operatio...
Real-World DevOps — 20 Practical Developers Tips for Tightening Your Operatio...Real-World DevOps — 20 Practical Developers Tips for Tightening Your Operatio...
Real-World DevOps — 20 Practical Developers Tips for Tightening Your Operatio...
 
State Machines and Workflow Nets on your PHP projects
State Machines and Workflow Nets on your PHP projectsState Machines and Workflow Nets on your PHP projects
State Machines and Workflow Nets on your PHP projects
 
Code on the Beach 2019 - Let's Take a Tour of .Net Core: CLI
Code on the Beach 2019 - Let's Take a Tour of .Net Core: CLICode on the Beach 2019 - Let's Take a Tour of .Net Core: CLI
Code on the Beach 2019 - Let's Take a Tour of .Net Core: CLI
 
Apache Mesos Distributed Computing Talk
Apache Mesos Distributed Computing Talk Apache Mesos Distributed Computing Talk
Apache Mesos Distributed Computing Talk
 
2017-10-24 All Day DevOps - Disposable Development Environments
2017-10-24 All Day DevOps - Disposable Development Environments2017-10-24 All Day DevOps - Disposable Development Environments
2017-10-24 All Day DevOps - Disposable Development Environments
 
Fullstack Academy - Awesome Web Dev Tips & Tricks
Fullstack Academy - Awesome Web Dev Tips & TricksFullstack Academy - Awesome Web Dev Tips & Tricks
Fullstack Academy - Awesome Web Dev Tips & Tricks
 
A Git MVP Workflow
A Git MVP WorkflowA Git MVP Workflow
A Git MVP Workflow
 
Continuous Cross Platform Mobile App Development using Jenkins Build Server
Continuous Cross Platform Mobile App Development using Jenkins Build ServerContinuous Cross Platform Mobile App Development using Jenkins Build Server
Continuous Cross Platform Mobile App Development using Jenkins Build Server
 
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
 
Introduction to Jenkins X
Introduction to Jenkins XIntroduction to Jenkins X
Introduction to Jenkins X
 
Intro to react_v2
Intro to react_v2Intro to react_v2
Intro to react_v2
 
Dev-Jam 2019 - Developing & Contributing to OpenNMS
Dev-Jam 2019 - Developing & Contributing to OpenNMSDev-Jam 2019 - Developing & Contributing to OpenNMS
Dev-Jam 2019 - Developing & Contributing to OpenNMS
 
Mono Repo
Mono RepoMono Repo
Mono Repo
 
Let's Count Bytes! Launching Ruby in 32K of RAM
Let's Count Bytes! Launching Ruby in 32K of RAMLet's Count Bytes! Launching Ruby in 32K of RAM
Let's Count Bytes! Launching Ruby in 32K of RAM
 
Xdebug for Beginners
Xdebug for BeginnersXdebug for Beginners
Xdebug for Beginners
 
Zenoss: Buildout
Zenoss: BuildoutZenoss: Buildout
Zenoss: Buildout
 
Serverless Preview Environments @ Boston DevOps
Serverless Preview Environments @ Boston DevOpsServerless Preview Environments @ Boston DevOps
Serverless Preview Environments @ Boston DevOps
 
Mocha, chai and sinon
Mocha, chai and sinonMocha, chai and sinon
Mocha, chai and sinon
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 
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
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 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
 
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
 

Introduction to React with MobX

  • 2. ABOUT AMBROSE ▸ Glad dad of 6 munchkins. ▸ Making pro software for ~18 years 
 Computer geek since 1987 ▸ Shipped over 45 projects, led over 20. 2 Patents. 
 Sometime dev, arch, UX guy, manager, PM, etc. ▸ 8x Microsoft MVP; Books, Blogs… ▸ Gone Skinning Dipping in Bulgarian Mountain Hot Springs
  • 3. INTRO TO REACT WITH MOBX THE PLAN ▸ Why MobX?
 In Which I Cover the Complete History of Functional State Management (j/k) ▸ Key Concepts
 A Bit Mind-bending but Easy to Use ▸ With the Showing of Some Examples
 Someone just told me these are the BEST examples!
  • 4. INTRO TO REACT WITH MOBX ABOUT YOU? ▸ Front End or Full Stack Dev ▸ Comfy with JavaScript, ideally ES2015+. ▸ You went to my last session or already are familiar with React. ▸ You are not a MobX expert.
  • 5. INTRO TO REACT WITH MOBX WHY MOBX? ▸ It Just Feels Right ▸ Easy to Use* ▸ Less Trouble than setState ▸ Simpler/Less Dogmatic
 then Redux ▸ Widely Used
 https://github.com/mobxjs/awesome-mobx
  • 6. INTRO TO REACT WITH MOBX PREFACE: GETTING MOBX ▸ https://reactjs.org/ <- First Get React ▸ https://mobx.js.org/ - Then Get MobX
 
 npm i mobx mobx-react —save
  • 8. INTRO TO REACT WITH MOBX COMPONENT COMMUNICATION PROPS DOWN EVENTS UP
  • 9. INTRO TO REACT WITH MOBX MOBX PROPS DOWN EVENTS UP STATE ACTIONS
  • 11. INTRO TO REACT WITH MOBX JUST ADD WATER! ▸ Add MobX to your project. ▸ Start decorating!
  • 13. INTRO TO REACT WITH MOBX DECORATE YOUR CLASSES (FUNCTIONS) AND PROPERTIES ▸ Declarative way to augment your code. (Similar to .NET Attributes) ▸ Syntax*: prefix thing:
 @[decorator][(options)] [thing] ▸ Very common for MobX: ▸ @observable myProp; ▸ @observer class MyComponent {} *Syntax is subject to change as this is a Stage 2 proposal.
  • 14. INTRO TO REACT WITH MOBX NB: USING DECORATORS WITH VS CODE ▸ Unless you like this: ▸ Add a tsconfig.json to your project root like this:
  • 15. INTRO TO REACT WITH MOBX BACK TO JUST ADDING WATER! ▸ Add MobX to your project. ▸ Start decorating!
  • 17. INTRO TO REACT WITH MOBX CAUTION: MOBX AND CREATE-REACT-APP ▸ CRA - Does not allow build config. Does not allow decorators (Stage 2). ▸ Option: Use without decorators
 https://github.com/benawad/simple-mobx/tree/1_counter ▸ Option: Use npm run eject
 https://swizec.com/blog/mobx-with-create-react-app/swizec/7158 ▸ Option: Use custom-react-scripts
 https://medium.com/@kitze/configure-create-react-app-without-ejecting- d8450e96196a ▸ More on with/without decorators: https://mobx.js.org/best/decorators.html
  • 18. INTRO TO REACT WITH MOBX CONVERTING CREATE-REACT-APP ▸ yarn remove react-scripts && yarn add custom-react-scripts ▸ Add .env file with REACT_APP_DECORATORS = true; ▸ npm i mobx mobx-react —save
  • 21. THE “STORE” KEY CONCEPT #5 STOOOOOOOORE… https://mobx.js.org/best/store.html
  • 22. OTHER “DERIVATIONS” AND GOODIES KEY CONCEPT #6 More at: https://mobx.js.org/intro/concepts.html
  • 23. INTRO TO REACT WITH MOBX COMPUTED ONE OF MY OBSERVABLES CHANGED HEY, I PROBABLY HAVE A NEW VALUE!
  • 24. INTRO TO REACT WITH MOBX REACTION ONE OF MY OBSERVABLES CHANGED Secret Agent Man
  • 25. INTRO TO REACT WITH MOBX OTHER GOODIES https://mobx.js.org/refguide/api.html Scroll down to Utilities isArrayLike!
  • 27. INTRO TO REACT WITH MOBX THAT’S IT! YOU’VE SEEN… ▸ What MobX is All About ▸ Unidirectional Data Flow ▸ Decorators: ▸ @observable ▸ @observer ▸ @computed ▸ How to Get More Reactive ▸ Modifying State with Actions ▸ Fancypants “Stores” ▸ Other Goodies
  • 28. REPETITIO MATER STUDIORUM EST. Ancient Dude INTRO TO REACT WITH MOBX
  • 29. REPETITION IS THE MOTHER OF ALL LEARNING. Dude What Speaks Modern English INTRO TO REACT WITH MOBX