SlideShare a Scribd company logo
1 of 23
SUBJECTIVE BEST
PRACTICES FOR REACT
WOJCIECH PIĄTKOWSKI
ARCHITECTURE DOCUMENTATION
▸ explains how to write features
▸ a contract between team
members
▸ unified way of getting pieces
together
▸ discussion about
architecture in one place
▸ newcomers can be quickly
introduced to
ARCHITECTURE DOCUMENTATION
▸ can get outdated easily
▸ it’s a theory
▸ no one really reads it :)
SCAFFOLDING
▸ it’s also a documentation
▸ provides real code that
can be reused very
quickly
Scaffolding Reflux Component
SCAFFOLDING
▸ used often thus it’s likely
to get update when
something changes.
Scaffolding Reflux Component
SCAFFOLDING
▸ you can easily write your own to match often custom needs of a project
▸ or use one of third party projects
Use example of
https://www.npmjs.com/package/react-scaffold
▸ or even fork one of those on
github too much your needs
REACT COMPONENTS CLEARNESS - DESTRUCTING PROPS AND STATE
D
E
S
T
R
U
C
T
E
D
REACT COMPONENTS CLEARNESS - DESTRUCTING PROPS AND STATE
D
E
S
T
R
U
C
T
E
D
REACT COMPONENTS CLEARNESS - DESTRUCTING PROPS AND STATE
NOT
D
E
S
T
R
U
C
T
E
D
SMART AND DUMP COMPONENTS
Smart component
- displays three dump
components
- connects to a store through
this.store = chairsStore
- triggers action
chairActions.createChair
Dump component
- displays simple form
- has no state
SMART AND DUMP COMPONENTS
Smart component
- div’s witch css classes were
added
- css classes holds
presentational function which
belongs to to dump
components
- chairs.css is imported
which adds styles to
elements with css classes
- thanks to it smart
components now holds also
presentational
Let’s delegate presentational
function to somewhere else…
SMART AND DUMP COMPONENTS
Smart component
- It’s previous presentational
features were moved to
ChairsManger
- ChairsManger receives
all it’s content via children
prop …
…which makes wrapping each
child separately very hard
SMART AND DUMP COMPONENTS
Smart component
- all props that previously were
sent to each child dumb
component, are grouped and
passed to ChairsManager
- ChairsManager does all
the presentational work
Making ChairsManager more flexible - #1
SMART AND DUMP COMPONENTS
Dump component
- recevies all props
- passes each prop to specific
child dump component
- there are no unique for
ChairsManager props
- a lot of props are just passed
further, they don’t do real job
here
Making ChairsManager more flexible - #1
SMART AND DUMP COMPONENTS
Smart component
- there are no data passed to
ChairsManager that would
normally be passed to dump
components
- Dump components itself are
passed to ChairsManager
Making ChairsManager more flexible - #2
SMART AND DUMP COMPONENTS
Dump component
- receives props
elements/components
through props
- those props may be
interpreted as slots where
other can components can fit
- there are no „dead” props
Making ChairsManager more flexible - #2
This is simplified example. In
real project structures are more
complicated. General idea is to
avoid having too many props
passes to a component only to
have them passed further.
PRACTICAL TESTING OF REACT COMPONENTS
Deep snapshot testing
- those test are super simple to
write
- thanks to scaffolding they
may require zero effort
- they don’t test behavior
- rather than that they are
freezing already working
component
- when any of its children is
changed the snapshot test
will alert us
- action can be taken if
necessary or simply quick
update of snapshot test
STYLES ENCAPSULATIONS
- globals styles should be
avoided
- styles can be easily
encapsulated with a css
class specific to a component
- effort of creating a new style
file for each component can
be minimized thanks to
scaffolding
- minimizes chances of styles
collision (some extra
strategies can be added like
project related prefixes)
- keep styling close to related
component - easier to
maintain
ComponentName.less
HOT MODULE RELOADING + REACT
- Working with minimalistic
source maps - eval
- faster bundling
- no problems with source
maps while using HMR
- target of babel transpiration
does not have to be ES5
which means even faster
bundling
- http://kangax.github.io/compa
t-table/es2016plus/
support of ES2016+ is great!
- babel-preset-env picks
minimal number of
transformers base on
specified target, e.g chrome
v61
- dev: ‚eval’
thanks to that modules are
displayed with generated
code which is close to ES6+
HOT MODULE RELOADING + REACT
- code is ES2016+ without
classes
- of course no JSX
- but the code is in general
readable
- and probably sooner or later
it will be possible not to
transform ES6 classes
HOT MODULE RELOADING + REACT
- unfortunately due to possible
bug in react-hot-loader
transformation of ES6
classes is necessary
- react-hot-loader
currency is in beta version:
3.0.0-beta.7
what gives hope that problem
soon will be solved
LAST WORDS - LINTING
▸ the sooner it’s set up the better
▸ introducing some of useful linters rules in late phase of the project is either impossible or very hard to do
so
▸ for those rules which does not support —fix it’s still possible to automize thanks to additional transformers
e.g. ESLints’s rule sort-comp has a separate transformer in react-codemod
▸ configuration of ESlint can be
accelerated by picking one of
already prepared config, e.g.
eslint-config-airbnb,
eslint-config-eslint
The full list of most popular configs
can be found at Github:
dustinspecker/awesome-eslint
Best Practices for React Architecture Documentation

More Related Content

What's hot

Continuous deployment of Rails apps on AWS OpsWorks
Continuous deployment of Rails apps on AWS OpsWorksContinuous deployment of Rails apps on AWS OpsWorks
Continuous deployment of Rails apps on AWS OpsWorksTomaž Zaman
 
Serverless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architectureServerless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architectureSandeep Paliwal
 
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...Puppet
 
.Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013
.Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013 .Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013
.Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013 Tikal Knowledge
 
Multi-stage Docker builds to make building easy!
Multi-stage Docker builds to make building easy!Multi-stage Docker builds to make building easy!
Multi-stage Docker builds to make building easy!Milindu Sanoj Kumarage
 
An introduction to Atlassian Bitbucket Pipelines
An introduction to Atlassian Bitbucket PipelinesAn introduction to Atlassian Bitbucket Pipelines
An introduction to Atlassian Bitbucket PipelinesDave Clark
 
Managing short lived Kubernetes (Production) deployments
Managing short lived Kubernetes (Production) deploymentsManaging short lived Kubernetes (Production) deployments
Managing short lived Kubernetes (Production) deploymentsHaufe-Lexware GmbH & Co KG
 
Continuous integration of_puppet_code
Continuous integration of_puppet_codeContinuous integration of_puppet_code
Continuous integration of_puppet_codeDevoteam Revolve
 
AWS CodeDeploy - basic intro
AWS CodeDeploy - basic introAWS CodeDeploy - basic intro
AWS CodeDeploy - basic introAnton Babenko
 
Beginner's Guide to Angular 2.0
Beginner's Guide to Angular 2.0Beginner's Guide to Angular 2.0
Beginner's Guide to Angular 2.0All Things Open
 
Serverless Cron Jobs with Ruby on Jets
Serverless Cron Jobs with Ruby on JetsServerless Cron Jobs with Ruby on Jets
Serverless Cron Jobs with Ruby on JetsTung Nguyen
 
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG WarsawAws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG WarsawServerless User Group Poland
 
Using Docker in Production
Using Docker in ProductionUsing Docker in Production
Using Docker in ProductionCloudHero
 
Continuous integration using atlassian bamboo
Continuous integration using atlassian bambooContinuous integration using atlassian bamboo
Continuous integration using atlassian bambooAlexander Masalov
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deckJames Ford
 
Modern Tools for Building Progressive Web Apps
Modern Tools for Building Progressive Web AppsModern Tools for Building Progressive Web Apps
Modern Tools for Building Progressive Web AppsAll Things Open
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyamlPuppet
 
Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18Maurice De Beijer [MVP]
 

What's hot (20)

Continuous deployment of Rails apps on AWS OpsWorks
Continuous deployment of Rails apps on AWS OpsWorksContinuous deployment of Rails apps on AWS OpsWorks
Continuous deployment of Rails apps on AWS OpsWorks
 
Serverless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architectureServerless meetup - OpenWhisk overview and architecture
Serverless meetup - OpenWhisk overview and architecture
 
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
 
.Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013
.Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013 .Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013
.Net OSS Ci & CD with Jenkins - JUC ISRAEL 2013
 
Multi-stage Docker builds to make building easy!
Multi-stage Docker builds to make building easy!Multi-stage Docker builds to make building easy!
Multi-stage Docker builds to make building easy!
 
An introduction to Atlassian Bitbucket Pipelines
An introduction to Atlassian Bitbucket PipelinesAn introduction to Atlassian Bitbucket Pipelines
An introduction to Atlassian Bitbucket Pipelines
 
Managing short lived Kubernetes (Production) deployments
Managing short lived Kubernetes (Production) deploymentsManaging short lived Kubernetes (Production) deployments
Managing short lived Kubernetes (Production) deployments
 
Continuous integration of_puppet_code
Continuous integration of_puppet_codeContinuous integration of_puppet_code
Continuous integration of_puppet_code
 
AWS CodeDeploy - basic intro
AWS CodeDeploy - basic introAWS CodeDeploy - basic intro
AWS CodeDeploy - basic intro
 
Beginner's Guide to Angular 2.0
Beginner's Guide to Angular 2.0Beginner's Guide to Angular 2.0
Beginner's Guide to Angular 2.0
 
Serverless Cron Jobs with Ruby on Jets
Serverless Cron Jobs with Ruby on JetsServerless Cron Jobs with Ruby on Jets
Serverless Cron Jobs with Ruby on Jets
 
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG WarsawAws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
 
Serverless
ServerlessServerless
Serverless
 
Using Docker in Production
Using Docker in ProductionUsing Docker in Production
Using Docker in Production
 
Continuous integration using atlassian bamboo
Continuous integration using atlassian bambooContinuous integration using atlassian bamboo
Continuous integration using atlassian bamboo
 
How Docker simplifies CI/CD
How Docker simplifies CI/CDHow Docker simplifies CI/CD
How Docker simplifies CI/CD
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
 
Modern Tools for Building Progressive Web Apps
Modern Tools for Building Progressive Web AppsModern Tools for Building Progressive Web Apps
Modern Tools for Building Progressive Web Apps
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyaml
 
Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18
 

Similar to Best Practices for React Architecture Documentation

From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...Alexander Dean
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014Rafe Colton
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...Docker, Inc.
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesdrupalindia
 
Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020Jesse Colligan
 
Docker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker, Inc.
 
Why you should consider a microframework for your next web project
Why you should consider a microframework for your next web projectWhy you should consider a microframework for your next web project
Why you should consider a microframework for your next web projectJoaquín Muñoz M.
 
Transformative Git Practices
Transformative Git PracticesTransformative Git Practices
Transformative Git PracticesNicola Paolucci
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureAdrian Otto
 
Serverless in production, an experience report (IWOMM)
Serverless in production, an experience report (IWOMM)Serverless in production, an experience report (IWOMM)
Serverless in production, an experience report (IWOMM)Yan Cui
 
Reuse, Reduce, Recycle in Serverless World
Reuse, Reduce, Recycle in Serverless WorldReuse, Reduce, Recycle in Serverless World
Reuse, Reduce, Recycle in Serverless WorldDmitri Zimine
 
Shipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOSShipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOSRoss Kukulinski
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arpGary Pedretti
 
InfluxCloudi craft container orchestrator
InfluxCloudi craft container orchestratorInfluxCloudi craft container orchestrator
InfluxCloudi craft container orchestratorGianluca Arbezzano
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsDavid Amend
 
FireWorks overview
FireWorks overviewFireWorks overview
FireWorks overviewAnubhav Jain
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsSteve Keener
 

Similar to Best Practices for React Architecture Documentation (20)

From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 
Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020
 
Docker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in Production
 
Why you should consider a microframework for your next web project
Why you should consider a microframework for your next web projectWhy you should consider a microframework for your next web project
Why you should consider a microframework for your next web project
 
Transformative Git Practices
Transformative Git PracticesTransformative Git Practices
Transformative Git Practices
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
 
Webpack: from 0 to 2
Webpack: from 0 to 2Webpack: from 0 to 2
Webpack: from 0 to 2
 
SCSS Styleguide
SCSS StyleguideSCSS Styleguide
SCSS Styleguide
 
Serverless in production, an experience report (IWOMM)
Serverless in production, an experience report (IWOMM)Serverless in production, an experience report (IWOMM)
Serverless in production, an experience report (IWOMM)
 
Reuse, Reduce, Recycle in Serverless World
Reuse, Reduce, Recycle in Serverless WorldReuse, Reduce, Recycle in Serverless World
Reuse, Reduce, Recycle in Serverless World
 
Shipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOSShipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOS
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
InfluxCloudi craft container orchestrator
InfluxCloudi craft container orchestratorInfluxCloudi craft container orchestrator
InfluxCloudi craft container orchestrator
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
 
Kash Kubernetified
Kash KubernetifiedKash Kubernetified
Kash Kubernetified
 
FireWorks overview
FireWorks overviewFireWorks overview
FireWorks overview
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 

Recently uploaded

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

Best Practices for React Architecture Documentation

  • 1. SUBJECTIVE BEST PRACTICES FOR REACT WOJCIECH PIĄTKOWSKI
  • 2. ARCHITECTURE DOCUMENTATION ▸ explains how to write features ▸ a contract between team members ▸ unified way of getting pieces together ▸ discussion about architecture in one place ▸ newcomers can be quickly introduced to
  • 3. ARCHITECTURE DOCUMENTATION ▸ can get outdated easily ▸ it’s a theory ▸ no one really reads it :)
  • 4. SCAFFOLDING ▸ it’s also a documentation ▸ provides real code that can be reused very quickly Scaffolding Reflux Component
  • 5. SCAFFOLDING ▸ used often thus it’s likely to get update when something changes. Scaffolding Reflux Component
  • 6. SCAFFOLDING ▸ you can easily write your own to match often custom needs of a project ▸ or use one of third party projects Use example of https://www.npmjs.com/package/react-scaffold ▸ or even fork one of those on github too much your needs
  • 7. REACT COMPONENTS CLEARNESS - DESTRUCTING PROPS AND STATE D E S T R U C T E D
  • 8. REACT COMPONENTS CLEARNESS - DESTRUCTING PROPS AND STATE D E S T R U C T E D
  • 9. REACT COMPONENTS CLEARNESS - DESTRUCTING PROPS AND STATE NOT D E S T R U C T E D
  • 10. SMART AND DUMP COMPONENTS Smart component - displays three dump components - connects to a store through this.store = chairsStore - triggers action chairActions.createChair Dump component - displays simple form - has no state
  • 11. SMART AND DUMP COMPONENTS Smart component - div’s witch css classes were added - css classes holds presentational function which belongs to to dump components - chairs.css is imported which adds styles to elements with css classes - thanks to it smart components now holds also presentational Let’s delegate presentational function to somewhere else…
  • 12. SMART AND DUMP COMPONENTS Smart component - It’s previous presentational features were moved to ChairsManger - ChairsManger receives all it’s content via children prop … …which makes wrapping each child separately very hard
  • 13. SMART AND DUMP COMPONENTS Smart component - all props that previously were sent to each child dumb component, are grouped and passed to ChairsManager - ChairsManager does all the presentational work Making ChairsManager more flexible - #1
  • 14. SMART AND DUMP COMPONENTS Dump component - recevies all props - passes each prop to specific child dump component - there are no unique for ChairsManager props - a lot of props are just passed further, they don’t do real job here Making ChairsManager more flexible - #1
  • 15. SMART AND DUMP COMPONENTS Smart component - there are no data passed to ChairsManager that would normally be passed to dump components - Dump components itself are passed to ChairsManager Making ChairsManager more flexible - #2
  • 16. SMART AND DUMP COMPONENTS Dump component - receives props elements/components through props - those props may be interpreted as slots where other can components can fit - there are no „dead” props Making ChairsManager more flexible - #2 This is simplified example. In real project structures are more complicated. General idea is to avoid having too many props passes to a component only to have them passed further.
  • 17. PRACTICAL TESTING OF REACT COMPONENTS Deep snapshot testing - those test are super simple to write - thanks to scaffolding they may require zero effort - they don’t test behavior - rather than that they are freezing already working component - when any of its children is changed the snapshot test will alert us - action can be taken if necessary or simply quick update of snapshot test
  • 18. STYLES ENCAPSULATIONS - globals styles should be avoided - styles can be easily encapsulated with a css class specific to a component - effort of creating a new style file for each component can be minimized thanks to scaffolding - minimizes chances of styles collision (some extra strategies can be added like project related prefixes) - keep styling close to related component - easier to maintain ComponentName.less
  • 19. HOT MODULE RELOADING + REACT - Working with minimalistic source maps - eval - faster bundling - no problems with source maps while using HMR - target of babel transpiration does not have to be ES5 which means even faster bundling - http://kangax.github.io/compa t-table/es2016plus/ support of ES2016+ is great! - babel-preset-env picks minimal number of transformers base on specified target, e.g chrome v61 - dev: ‚eval’ thanks to that modules are displayed with generated code which is close to ES6+
  • 20. HOT MODULE RELOADING + REACT - code is ES2016+ without classes - of course no JSX - but the code is in general readable - and probably sooner or later it will be possible not to transform ES6 classes
  • 21. HOT MODULE RELOADING + REACT - unfortunately due to possible bug in react-hot-loader transformation of ES6 classes is necessary - react-hot-loader currency is in beta version: 3.0.0-beta.7 what gives hope that problem soon will be solved
  • 22. LAST WORDS - LINTING ▸ the sooner it’s set up the better ▸ introducing some of useful linters rules in late phase of the project is either impossible or very hard to do so ▸ for those rules which does not support —fix it’s still possible to automize thanks to additional transformers e.g. ESLints’s rule sort-comp has a separate transformer in react-codemod ▸ configuration of ESlint can be accelerated by picking one of already prepared config, e.g. eslint-config-airbnb, eslint-config-eslint The full list of most popular configs can be found at Github: dustinspecker/awesome-eslint