SlideShare a Scribd company logo
1 of 45
Download to read offline
@YourTwitterHandle
Your blog / Website
YOUR NAME
Mohamed EL AYADI
@incepterr
React
A JavaScript library
React
A JavaScript library
A UI runtime that run components
React
A JavaScript library
A UI runtime that run components
A set of packages and renderers of different hosts
environments
whoami
Mohamed EL AYADI
Senior software engineer with a decade of experience
Java & JavaScript ecosystems
@incepter
@incepterr
Plan
What x Is x State ?
State crimes x And x State police
State x Management x Aspects
Conclusion x And x Takeaways
What x Is x State ?
• It is the internal memory of a react component
• State setter is the only trigger of the update phase in react
• OK, may be useSyncExternalStore also, but not trivial
• Some states need to be shared in a tree
• Shared by prop drilling or wired via context Api.
• Asynchronous states update state later.
State crimes x And x State police
• Cannot update state of unmounted component
• Showing results of earlier request
• No cancellations
• No pending states
• Poor error handling
• Useless useEffects
• Flashing old state
• No sharing
• The list doesn’t end here…
State crimes x And x State police
• Cannot update state of unmounted component
State crimes x And x State police
• Cannot update state of unmounted component
State crimes x And x State police
• Cannot update state of unmounted component
State crimes x And x State police
• Problems with this code
• The loading state isn’t a Boolean
• Three pieces of states working and updated together
• Counting rather than a Boolean semaphore
• Doesn’t abort the previous call
State crimes x And x State police
• Cannot update state of unmounted component
State crimes x And x State police
• Cannot update state of unmounted component
State crimes x And x State police
• Cannot update state of unmounted component
State crimes x And x State police
• Showing results of earlier request
State crimes x And x State police
• Showing results of earlier request
State crimes x And x State police
• No cancellations
• AbortController
State crimes x And x State police
• No cancellations
State crimes x And x State police
• No cancellations
State crimes x And x State police
• No cancellations
State crimes x And x State police
• No cancellations
State crimes x And x State police
• No pending states
State crimes x And x State police
• No pending states
• Exact status
• The data relative to the status
• The date at which this piece of state was constructed
• The props that led to that state outcome, may be used for optimistic UI.
State crimes x And x State police
• Poor error handlig
State crimes x And x State police
• Useless effects
• Could be done in event handlers
• Only to reset state from props
• Effects are only for synchronization and subscription
State crimes x And x State police
• Useless effects
• Could be done in event handlers
• Only to reset state from props
• Effects are only for synchronization and subscription
State crimes x And x State police
• Useless effects
• Could be done in event handlers
• Only to reset state from props
• Effects are only for synchronization and subscription
State crimes x And x State police
• Flashing old state
• Previous state shows for few Millis and then we start a pending state (if lucky
enough!)
State crimes x And x State police
• Manipulating refs and using state to re-render
• The list doesn’t end here…
State crimes x And x State police
• Linters provide great help to follow the rules of hooks
• Rules of hooks
• Exhaustive deps
• …
• Blog posts and tutorials try their maximum to share good practices
• Dan’s overreacted blog
• Kent’s blogs and learning material
• Community libraries makes our life easier
• UI libraries
• State managers
• XState
• State managers leverage the complexity but create bad habits.
• React Strict Mode
State x Management x Aspects
• Sharing
• Subscriptions
• Asynchronous flows
• Cancellations
• Forks
• Effects: debounce, throttle, delay…
• Caching (with/without persistence)
• React/root independent
• Sharing
State x Management x Aspects
• Subscriptions
State x Management x Aspects
• Subscriptions
State x Management x Aspects
• Asynchronous flows
State x Management x Aspects
• Cancellations
• Generators support
• Async/await support via isAborted
• Abort callbacks registration and invalidation
State x Management x Aspects
• Forks
• Replicate behavior for a new tree
State x Management x Aspects
• Effects: debounce, throttle, delay…
State x Management x Aspects
• Caching (with/without persistence)
• Invalidate and refetch when timed-out
• Only invalidate when requested and state
State x Management x Aspects
• React/root independent
State x Management x Aspects
State x Management x Aspects
State x Management x Aspects
Conclusion x And x Takeaways
• State is the only trigger of updates in react (re-renders). Ok, useSES!
• State setter must be secured from old and stale closures, not only unmount.
• If React.useCallback could just invalidate the previous callback when deps
change!
• Status is mandatory when dealing with asynchronous states
• useEffect should not be abused and events should perform more work
• State managers offers great help dealing with state
• Community resources are a gem that should be considered more
• We are all state criminals
Mohamed EL AYADI
@incepterr

More Related Content

What's hot

What it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! PerspectivesWhat it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! PerspectivesDataWorks Summit
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm Chandler Huang
 
(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep DiveAmazon Web Services
 
SMC304 Serverless Orchestration with AWS Step Functions
SMC304 Serverless Orchestration with AWS Step FunctionsSMC304 Serverless Orchestration with AWS Step Functions
SMC304 Serverless Orchestration with AWS Step FunctionsAmazon Web Services
 
Zookeeper Architecture
Zookeeper ArchitectureZookeeper Architecture
Zookeeper ArchitecturePrasad Wali
 
The Evolution of a Relational Database Layer over HBase
The Evolution of a Relational Database Layer over HBaseThe Evolution of a Relational Database Layer over HBase
The Evolution of a Relational Database Layer over HBaseDataWorks Summit
 
Integrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your EnvironmentIntegrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your Environmentconfluent
 
Glusterfs and openstack
Glusterfs  and openstackGlusterfs  and openstack
Glusterfs and openstackopenstackindia
 
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache KafkaReal-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache KafkaKai Wähner
 
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...confluent
 
Apache Beam: A unified model for batch and stream processing data
Apache Beam: A unified model for batch and stream processing dataApache Beam: A unified model for batch and stream processing data
Apache Beam: A unified model for batch and stream processing dataDataWorks Summit/Hadoop Summit
 
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...HostedbyConfluent
 
Top 5 Mistakes When Writing Spark Applications by Mark Grover and Ted Malaska
Top 5 Mistakes When Writing Spark Applications by Mark Grover and Ted MalaskaTop 5 Mistakes When Writing Spark Applications by Mark Grover and Ted Malaska
Top 5 Mistakes When Writing Spark Applications by Mark Grover and Ted MalaskaSpark Summit
 
Migrating Oracle database to Cassandra
Migrating Oracle database to CassandraMigrating Oracle database to Cassandra
Migrating Oracle database to CassandraUmair Mansoob
 
Openshift serverless Solution
Openshift serverless SolutionOpenshift serverless Solution
Openshift serverless SolutionRyan ZhangCheng
 
Managing your Hadoop Clusters with Apache Ambari
Managing your Hadoop Clusters with Apache AmbariManaging your Hadoop Clusters with Apache Ambari
Managing your Hadoop Clusters with Apache AmbariDataWorks Summit
 
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow FlightThe Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow FlightDatabricks
 
OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...
OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...
OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...Altinity Ltd
 

What's hot (20)

What it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! PerspectivesWhat it takes to run Hadoop at Scale: Yahoo! Perspectives
What it takes to run Hadoop at Scale: Yahoo! Perspectives
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
 
(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive(CMP402) Amazon EC2 Instances Deep Dive
(CMP402) Amazon EC2 Instances Deep Dive
 
SMC304 Serverless Orchestration with AWS Step Functions
SMC304 Serverless Orchestration with AWS Step FunctionsSMC304 Serverless Orchestration with AWS Step Functions
SMC304 Serverless Orchestration with AWS Step Functions
 
Zookeeper Architecture
Zookeeper ArchitectureZookeeper Architecture
Zookeeper Architecture
 
The Evolution of a Relational Database Layer over HBase
The Evolution of a Relational Database Layer over HBaseThe Evolution of a Relational Database Layer over HBase
The Evolution of a Relational Database Layer over HBase
 
Integrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your EnvironmentIntegrating Apache Kafka Into Your Environment
Integrating Apache Kafka Into Your Environment
 
Glusterfs and openstack
Glusterfs  and openstackGlusterfs  and openstack
Glusterfs and openstack
 
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache KafkaReal-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
 
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
From Zero to Hero with Kafka Connect (Robin Moffat, Confluent) Kafka Summit L...
 
Apache Beam: A unified model for batch and stream processing data
Apache Beam: A unified model for batch and stream processing dataApache Beam: A unified model for batch and stream processing data
Apache Beam: A unified model for batch and stream processing data
 
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...
 
Top 5 Mistakes When Writing Spark Applications by Mark Grover and Ted Malaska
Top 5 Mistakes When Writing Spark Applications by Mark Grover and Ted MalaskaTop 5 Mistakes When Writing Spark Applications by Mark Grover and Ted Malaska
Top 5 Mistakes When Writing Spark Applications by Mark Grover and Ted Malaska
 
Ipfs
IpfsIpfs
Ipfs
 
Migrating Oracle database to Cassandra
Migrating Oracle database to CassandraMigrating Oracle database to Cassandra
Migrating Oracle database to Cassandra
 
Openshift serverless Solution
Openshift serverless SolutionOpenshift serverless Solution
Openshift serverless Solution
 
Managing your Hadoop Clusters with Apache Ambari
Managing your Hadoop Clusters with Apache AmbariManaging your Hadoop Clusters with Apache Ambari
Managing your Hadoop Clusters with Apache Ambari
 
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow FlightThe Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
 
Data Stores @ Netflix
Data Stores @ NetflixData Stores @ Netflix
Data Stores @ Netflix
 
OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...
OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...
OSA Con 2022 - Arrow in Flight_ New Developments in Data Connectivity - David...
 

Similar to Revisiting x State x Management.pdf

Revisiting x State x Management__blablaconf.pptx
Revisiting x State x Management__blablaconf.pptxRevisiting x State x Management__blablaconf.pptx
Revisiting x State x Management__blablaconf.pptxMohamedElAyadi9
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application DesignGlobalLogic Ukraine
 
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...Russell Beggs
 
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...European SharePoint Conference
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application DesignOrkhan Gasimov
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)Tomáš Drenčák
 
Vasyl Sydorivskiy - Angular Functional Style
Vasyl Sydorivskiy - Angular Functional StyleVasyl Sydorivskiy - Angular Functional Style
Vasyl Sydorivskiy - Angular Functional StyleInnovecs
 
Rsqrd AI: Zestimates and Zillow AI Platform
Rsqrd AI: Zestimates and Zillow AI PlatformRsqrd AI: Zestimates and Zillow AI Platform
Rsqrd AI: Zestimates and Zillow AI PlatformSanjana Chowdhury
 
Brighttalk high scale low touch and other bedtime stories - final
Brighttalk   high scale low touch and other bedtime stories - finalBrighttalk   high scale low touch and other bedtime stories - final
Brighttalk high scale low touch and other bedtime stories - finalAndrew White
 
Dumb and smart components + redux (1)
Dumb and smart components + redux (1)Dumb and smart components + redux (1)
Dumb and smart components + redux (1)Brecht Billiet
 
Unit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programmingUnit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programmingLeahRachael
 
Cloud-based Modelling Solutions Empowering Tool Integration
Cloud-based Modelling Solutions Empowering Tool IntegrationCloud-based Modelling Solutions Empowering Tool Integration
Cloud-based Modelling Solutions Empowering Tool IntegrationIstvan Rath
 
Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...
Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...
Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...HostedbyConfluent
 
Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.jhugg
 
Robust UI development with ClojureScript
Robust UI development with ClojureScriptRobust UI development with ClojureScript
Robust UI development with ClojureScriptSandilya Jandhyala
 
FRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptxFRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptxEhtesham46
 

Similar to Revisiting x State x Management.pdf (20)

Revisiting x State x Management__blablaconf.pptx
Revisiting x State x Management__blablaconf.pptxRevisiting x State x Management__blablaconf.pptx
Revisiting x State x Management__blablaconf.pptx
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application Design
 
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
 
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...
State Machine Workflow: Esoteric Techniques & Patterns Everyone Should Buy pr...
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application Design
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)
 
React introduction
React introductionReact introduction
React introduction
 
Vasyl Sydorivskiy - Angular Functional Style
Vasyl Sydorivskiy - Angular Functional StyleVasyl Sydorivskiy - Angular Functional Style
Vasyl Sydorivskiy - Angular Functional Style
 
Rsqrd AI: Zestimates and Zillow AI Platform
Rsqrd AI: Zestimates and Zillow AI PlatformRsqrd AI: Zestimates and Zillow AI Platform
Rsqrd AI: Zestimates and Zillow AI Platform
 
Rubyslava #70
Rubyslava #70Rubyslava #70
Rubyslava #70
 
Brighttalk high scale low touch and other bedtime stories - final
Brighttalk   high scale low touch and other bedtime stories - finalBrighttalk   high scale low touch and other bedtime stories - final
Brighttalk high scale low touch and other bedtime stories - final
 
Dumb and smart components + redux (1)
Dumb and smart components + redux (1)Dumb and smart components + redux (1)
Dumb and smart components + redux (1)
 
Unit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programmingUnit 4- State Machine in mobile programming
Unit 4- State Machine in mobile programming
 
Cloud-based Modelling Solutions Empowering Tool Integration
Cloud-based Modelling Solutions Empowering Tool IntegrationCloud-based Modelling Solutions Empowering Tool Integration
Cloud-based Modelling Solutions Empowering Tool Integration
 
Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...
Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...
Continuous Intelligence for Customer Service Using Kafka Event Streams | Simo...
 
Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.
 
Robust UI development with ClojureScript
Robust UI development with ClojureScriptRobust UI development with ClojureScript
Robust UI development with ClojureScript
 
FRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptxFRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptx
 
Computer Reliability
Computer ReliabilityComputer Reliability
Computer Reliability
 
Effective Akka v2.0 - Jamie Allen
Effective Akka v2.0 - Jamie AllenEffective Akka v2.0 - Jamie Allen
Effective Akka v2.0 - Jamie Allen
 

Recently uploaded

Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...ScyllaDB
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 

Recently uploaded (20)

Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 

Revisiting x State x Management.pdf

  • 1. @YourTwitterHandle Your blog / Website YOUR NAME Mohamed EL AYADI @incepterr
  • 3. React A JavaScript library A UI runtime that run components
  • 4. React A JavaScript library A UI runtime that run components A set of packages and renderers of different hosts environments
  • 5. whoami Mohamed EL AYADI Senior software engineer with a decade of experience Java & JavaScript ecosystems @incepter @incepterr
  • 6. Plan What x Is x State ? State crimes x And x State police State x Management x Aspects Conclusion x And x Takeaways
  • 7. What x Is x State ? • It is the internal memory of a react component • State setter is the only trigger of the update phase in react • OK, may be useSyncExternalStore also, but not trivial • Some states need to be shared in a tree • Shared by prop drilling or wired via context Api. • Asynchronous states update state later.
  • 8. State crimes x And x State police • Cannot update state of unmounted component • Showing results of earlier request • No cancellations • No pending states • Poor error handling • Useless useEffects • Flashing old state • No sharing • The list doesn’t end here…
  • 9. State crimes x And x State police • Cannot update state of unmounted component
  • 10. State crimes x And x State police • Cannot update state of unmounted component
  • 11. State crimes x And x State police • Cannot update state of unmounted component
  • 12. State crimes x And x State police • Problems with this code • The loading state isn’t a Boolean • Three pieces of states working and updated together • Counting rather than a Boolean semaphore • Doesn’t abort the previous call
  • 13. State crimes x And x State police • Cannot update state of unmounted component
  • 14. State crimes x And x State police • Cannot update state of unmounted component
  • 15. State crimes x And x State police • Cannot update state of unmounted component
  • 16. State crimes x And x State police • Showing results of earlier request
  • 17. State crimes x And x State police • Showing results of earlier request
  • 18. State crimes x And x State police • No cancellations • AbortController
  • 19. State crimes x And x State police • No cancellations
  • 20. State crimes x And x State police • No cancellations
  • 21. State crimes x And x State police • No cancellations
  • 22. State crimes x And x State police • No cancellations
  • 23. State crimes x And x State police • No pending states
  • 24. State crimes x And x State police • No pending states • Exact status • The data relative to the status • The date at which this piece of state was constructed • The props that led to that state outcome, may be used for optimistic UI.
  • 25. State crimes x And x State police • Poor error handlig
  • 26. State crimes x And x State police • Useless effects • Could be done in event handlers • Only to reset state from props • Effects are only for synchronization and subscription
  • 27. State crimes x And x State police • Useless effects • Could be done in event handlers • Only to reset state from props • Effects are only for synchronization and subscription
  • 28. State crimes x And x State police • Useless effects • Could be done in event handlers • Only to reset state from props • Effects are only for synchronization and subscription
  • 29. State crimes x And x State police • Flashing old state • Previous state shows for few Millis and then we start a pending state (if lucky enough!)
  • 30. State crimes x And x State police • Manipulating refs and using state to re-render • The list doesn’t end here…
  • 31. State crimes x And x State police • Linters provide great help to follow the rules of hooks • Rules of hooks • Exhaustive deps • … • Blog posts and tutorials try their maximum to share good practices • Dan’s overreacted blog • Kent’s blogs and learning material • Community libraries makes our life easier • UI libraries • State managers • XState • State managers leverage the complexity but create bad habits. • React Strict Mode
  • 32. State x Management x Aspects • Sharing • Subscriptions • Asynchronous flows • Cancellations • Forks • Effects: debounce, throttle, delay… • Caching (with/without persistence) • React/root independent
  • 33. • Sharing State x Management x Aspects
  • 34. • Subscriptions State x Management x Aspects
  • 35. • Subscriptions State x Management x Aspects
  • 36. • Asynchronous flows State x Management x Aspects
  • 37. • Cancellations • Generators support • Async/await support via isAborted • Abort callbacks registration and invalidation State x Management x Aspects
  • 38. • Forks • Replicate behavior for a new tree State x Management x Aspects
  • 39. • Effects: debounce, throttle, delay… State x Management x Aspects
  • 40. • Caching (with/without persistence) • Invalidate and refetch when timed-out • Only invalidate when requested and state State x Management x Aspects
  • 41. • React/root independent State x Management x Aspects
  • 42. State x Management x Aspects
  • 43. State x Management x Aspects
  • 44. Conclusion x And x Takeaways • State is the only trigger of updates in react (re-renders). Ok, useSES! • State setter must be secured from old and stale closures, not only unmount. • If React.useCallback could just invalidate the previous callback when deps change! • Status is mandatory when dealing with asynchronous states • useEffect should not be abused and events should perform more work • State managers offers great help dealing with state • Community resources are a gem that should be considered more • We are all state criminals