SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Zack Argyle
Building Open Source
React Components
1
2
3
4
Just a guy that loves software and his kid, but mostly software.
Introduction
Playstation
Javascript Engineer
Harman
Audio Hardware Engineer
Verisage
Software Consulting
Pinterest
Full-Stack Engineer
San Mateo
Dad
Twitter:
@zackargyl
Github:
github.com/zackargyl
Medium:
medium.com/@zackargyle/
6
react-pinterest
Confidential 7
Building Your Component
8
What’s on the
Agenda?
9
1. Building the component
2. Open sourcing to Github
3. Publishing to NPM
Building the Component
10
• PropTypes + DefaultProps
• Tests
• Linting
• README.md
• Example usage
• Lightweight
• Encapsulated
• Stateless (if possible)
• Performant
• Minimal dependencies
PropTypes + DefaultProps
11
The bane of every open-source developer’s existence is argument validation.
• Ain’t nobody got time to add hundreds of lines of validation to make sure people are putting the right
crap in the right spots
• Be specific
Bad
• PropTypes.array
Good
• PropTypes.arrayOf(PropTypes.number)
• Add .isRequired for all required properties
• Add a defaultProp value for all non-required properties
• Comment about what the prop does in either the class documentation (@prop) or at the PropType
declaration.
PropTypes are Elegant
12
Testing
13
When contributors make changes, good tests will give you the confidence to merge.
• Add fixtures to make adding tests easier.
• Test UI. The beautiful thing about React is that you can shallow render a component and make
assertions against what you know it should look like.
• Test methods. Test key internal component methods against edge cases.
• Test everything you can. Not sure if you should test it === yes.
• Require tests from all incoming PRs that change more than configurations / typos
• Which testing framework should you use?
Testing is Key
14
15
Linting
16
Never trust yourself to catch what automation can catch.
• It’s a one-time configuration that gives back to the
project in abundance.
• Saves you from being the butthole owner that nit picks
every PR. Can you say scapegoat?
• When contributing to a codebase it’s nice to have a
standard to code towards.
• There is literally no downside to linting. Ok maybe there
are one or two.
Linting Saves Time
17
README.md
18
Don’t slack off on documentation.
The 3 Things Every README Needs
19
Pictures
Always show a visual
representation of what your
component does
Props Dev Tips
2 3
Add a table or some simple
way of seeing what props
are available for use
Provide tips on how to get
started in contributing to
the component
1
NPM
20
There’s a lot of little things to learn, so break it down.
• devDependencies - Any dependencies that are requirements for contributing to the component.
• peerDependencies - This means that your component is like a plugin for a given dependency. It will
not install the dependency itself, but expects it to be there. Ours has `react` as a peer dep.
• dependencies - Any dependencies that are requirements for production.
• files - List of directories/files to be included when npm installed. You can
conversely use a .npmignore file to exclude directories/files.
• main - Path to the file that should be referenced when `required` (the dist file).
• jsnext:main - Like main, but points to an ES2015 file (the src file).
• keywords - These are `tags` for your component. Make sure to at least include
`react` and `react-component`.
package.json
21
You can create your own, or tie into keywords.
Scripts
22
• start - Typically used for starting your development server ( ie., cd example && node server.js ).
• test - Runs the unit tests for your component ( ie., node_modules/.bin/karma start karma.config.js ).
• build - Compiles/minifies your src directory ( ie., npm run clean && webpack --config
webpack.config.js ).
• lint - Runs the linters to verify code quality ( ie., ./node_modules/eslint/bin/eslint.js src ).
• prepublish - Runs before publishing to NPM. Typically runs build ( ie., npm run build ).
"scripts": {
"build": "npm run clean && webpack --config webpack.config.js",
"clean": "rimraf dist lib",
"lint": "./node_modules/eslint/bin/eslint.js src",
"prepublish": "npm run build",
"start": "cd example && node server.js",
"test": "node_modules/.bin/karma start karma.config.js”
}
Just use MIT, it’s popular and truly open.
Licenses
23
All public projects on NPM are free to create and maintain.
Getting Started with NPM
24
• Create your account -NPM Sign up
• Command Line
npm login: use the credentials for the user you just created
npm publish
• README - Make sure your component page looks good on npmjs.com
Go check it out at https://www.npmjs.com/package/<component_name>
• Try it - Make sure your project installs correctly (npm install <component_name>)
Semantic Versioning
25
“Semantic versioning is a standard that a lot of projects use to communicate
what kinds of changes are in this release. It's important to communicate what kinds
of changes are in a release because sometimes those changes will break the code
that depends on the package.” - NPM
Use the correct versioning to ensure compatibility for your users.
Versioning
26
• 1.0.0 - Publish to NPM.
 npm publish
• 1.0.1 - Patch release. Bug fixes or minor changes.
 npm version patch -m “[B124] Fixes some bug”
• 1.1.0 - Minor release. New feature with backwards compatibility.
 npm version minor -m “Adds X feature”
• 2.0.0 - Major release. New features that break old versions.
 npm version major -m “Architecture change for X”
Let’s check out the demo!
27
react-image-layout
28
 Lightweight
 Encapsulated
 Stateless (if possible)
 Performant
 Minimal
 PropTypes + DefaultProps
 Tests (UI + unit)
 Linters
 README (pictures, props, tips)
 Example Usage
 Package.json
Thank you!
29
Twitter: @zackargyle
medium.com/~zackargyle
github.com/zackargyle
zackargyle@pinterest.com

Weitere ähnliche Inhalte

Was ist angesagt?

SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsPablo Godel
 
Javascript test frameworks
Javascript test frameworksJavascript test frameworks
Javascript test frameworkstalkitbr
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016Gavin Pickin
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices WorkshopAhmed AbouZaid
 
Ansible, Idempotency, and Jenkins
Ansible, Idempotency, and JenkinsAnsible, Idempotency, and Jenkins
Ansible, Idempotency, and Jenkinstylerturk
 
[123] quality without qa
[123] quality without qa[123] quality without qa
[123] quality without qaNAVER D2
 
Rooted con 2020 - from the heaven to hell in the CI - CD
Rooted con 2020 - from the heaven to hell in the CI - CDRooted con 2020 - from the heaven to hell in the CI - CD
Rooted con 2020 - from the heaven to hell in the CI - CDDaniel Garcia (a.k.a cr0hn)
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018Viresh Doshi
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad WoodOrtus Solutions, Corp
 
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 -  Rock Solid Deployment of Symfony AppsSymfony Live NYC 2014 -  Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony AppsPablo Godel
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chefice799
 
Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Giorgio Cefaro
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Danny Preussler
 
ContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureYury Tsarev
 
CommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementCommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementOrtus Solutions, Corp
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous IntegrationMichael Peters
 

Was ist angesagt? (19)

SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
 
Javascript test frameworks
Javascript test frameworksJavascript test frameworks
Javascript test frameworks
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
 
Ansible, Idempotency, and Jenkins
Ansible, Idempotency, and JenkinsAnsible, Idempotency, and Jenkins
Ansible, Idempotency, and Jenkins
 
[123] quality without qa
[123] quality without qa[123] quality without qa
[123] quality without qa
 
Testing Automaton - CFSummit 2016
Testing Automaton - CFSummit 2016Testing Automaton - CFSummit 2016
Testing Automaton - CFSummit 2016
 
12 tricks to avoid hackers breaks your CI / CD
12 tricks to avoid hackers breaks your  CI / CD12 tricks to avoid hackers breaks your  CI / CD
12 tricks to avoid hackers breaks your CI / CD
 
Rooted con 2020 - from the heaven to hell in the CI - CD
Rooted con 2020 - from the heaven to hell in the CI - CDRooted con 2020 - from the heaven to hell in the CI - CD
Rooted con 2020 - from the heaven to hell in the CI - CD
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Wood
 
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 -  Rock Solid Deployment of Symfony AppsSymfony Live NYC 2014 -  Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chef
 
Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
ContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven Infrastructure
 
CommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementCommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package Management
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous Integration
 

Ähnlich wie Building Open-source React Components

Getting Started with Node.js
Getting Started with Node.jsGetting Started with Node.js
Getting Started with Node.jsJustin Reock
 
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...Codemotion
 
ASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerJürgen Gutsch
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplateStanislav Petrov
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JSJacob Nelson
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodeKris Buytaert
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)p3castro
 
Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsSebastian Springer
 
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviUnderstanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviCysinfo Cyber Security Community
 
Node Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsNode Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsChetan Desai
 
2014 land your-first_patch_neutron
2014 land your-first_patch_neutron2014 land your-first_patch_neutron
2014 land your-first_patch_neutronRossella Sblendido
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development WorkflowJeffery Smith
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development PipelineGlobalLogic Ukraine
 
Android lint presentation
Android lint presentationAndroid lint presentation
Android lint presentationSinan KOZAK
 

Ähnlich wie Building Open-source React Components (20)

Getting Started with Node.js
Getting Started with Node.jsGetting Started with Node.js
Getting Started with Node.js
 
Nodeconf npm 2011
Nodeconf npm 2011Nodeconf npm 2011
Nodeconf npm 2011
 
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
 
Cypress for Testing
Cypress for TestingCypress for Testing
Cypress for Testing
 
ASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & dockerASP.NET 5 auf Raspberry PI & docker
ASP.NET 5 auf Raspberry PI & docker
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
CI
CICI
CI
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Creating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.jsCreating Enterprise Web Applications with Node.js
Creating Enterprise Web Applications with Node.js
 
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram KharviUnderstanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
 
Node Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsNode Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.js
 
Devops
DevopsDevops
Devops
 
2014 land your-first_patch_neutron
2014 land your-first_patch_neutron2014 land your-first_patch_neutron
2014 land your-first_patch_neutron
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
 
Android lint presentation
Android lint presentationAndroid lint presentation
Android lint presentation
 

Kürzlich hochgeladen

Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate productionChinnuNinan
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
BSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptxBSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptxNiranjanYadav41
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 

Kürzlich hochgeladen (20)

Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate production
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
BSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptxBSNL Internship Training presentation.pptx
BSNL Internship Training presentation.pptx
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 

Building Open-source React Components

  • 1. Zack Argyle Building Open Source React Components 1
  • 2. 2
  • 3. 3
  • 4. 4
  • 5. Just a guy that loves software and his kid, but mostly software. Introduction Playstation Javascript Engineer Harman Audio Hardware Engineer Verisage Software Consulting Pinterest Full-Stack Engineer San Mateo Dad Twitter: @zackargyl Github: github.com/zackargyl Medium: medium.com/@zackargyle/
  • 9. What’s on the Agenda? 9 1. Building the component 2. Open sourcing to Github 3. Publishing to NPM
  • 10. Building the Component 10 • PropTypes + DefaultProps • Tests • Linting • README.md • Example usage • Lightweight • Encapsulated • Stateless (if possible) • Performant • Minimal dependencies
  • 12. The bane of every open-source developer’s existence is argument validation. • Ain’t nobody got time to add hundreds of lines of validation to make sure people are putting the right crap in the right spots • Be specific Bad • PropTypes.array Good • PropTypes.arrayOf(PropTypes.number) • Add .isRequired for all required properties • Add a defaultProp value for all non-required properties • Comment about what the prop does in either the class documentation (@prop) or at the PropType declaration. PropTypes are Elegant 12
  • 14. When contributors make changes, good tests will give you the confidence to merge. • Add fixtures to make adding tests easier. • Test UI. The beautiful thing about React is that you can shallow render a component and make assertions against what you know it should look like. • Test methods. Test key internal component methods against edge cases. • Test everything you can. Not sure if you should test it === yes. • Require tests from all incoming PRs that change more than configurations / typos • Which testing framework should you use? Testing is Key 14
  • 15. 15
  • 17. Never trust yourself to catch what automation can catch. • It’s a one-time configuration that gives back to the project in abundance. • Saves you from being the butthole owner that nit picks every PR. Can you say scapegoat? • When contributing to a codebase it’s nice to have a standard to code towards. • There is literally no downside to linting. Ok maybe there are one or two. Linting Saves Time 17
  • 19. Don’t slack off on documentation. The 3 Things Every README Needs 19 Pictures Always show a visual representation of what your component does Props Dev Tips 2 3 Add a table or some simple way of seeing what props are available for use Provide tips on how to get started in contributing to the component 1
  • 21. There’s a lot of little things to learn, so break it down. • devDependencies - Any dependencies that are requirements for contributing to the component. • peerDependencies - This means that your component is like a plugin for a given dependency. It will not install the dependency itself, but expects it to be there. Ours has `react` as a peer dep. • dependencies - Any dependencies that are requirements for production. • files - List of directories/files to be included when npm installed. You can conversely use a .npmignore file to exclude directories/files. • main - Path to the file that should be referenced when `required` (the dist file). • jsnext:main - Like main, but points to an ES2015 file (the src file). • keywords - These are `tags` for your component. Make sure to at least include `react` and `react-component`. package.json 21
  • 22. You can create your own, or tie into keywords. Scripts 22 • start - Typically used for starting your development server ( ie., cd example && node server.js ). • test - Runs the unit tests for your component ( ie., node_modules/.bin/karma start karma.config.js ). • build - Compiles/minifies your src directory ( ie., npm run clean && webpack --config webpack.config.js ). • lint - Runs the linters to verify code quality ( ie., ./node_modules/eslint/bin/eslint.js src ). • prepublish - Runs before publishing to NPM. Typically runs build ( ie., npm run build ). "scripts": { "build": "npm run clean && webpack --config webpack.config.js", "clean": "rimraf dist lib", "lint": "./node_modules/eslint/bin/eslint.js src", "prepublish": "npm run build", "start": "cd example && node server.js", "test": "node_modules/.bin/karma start karma.config.js” }
  • 23. Just use MIT, it’s popular and truly open. Licenses 23
  • 24. All public projects on NPM are free to create and maintain. Getting Started with NPM 24 • Create your account -NPM Sign up • Command Line npm login: use the credentials for the user you just created npm publish • README - Make sure your component page looks good on npmjs.com Go check it out at https://www.npmjs.com/package/<component_name> • Try it - Make sure your project installs correctly (npm install <component_name>)
  • 25. Semantic Versioning 25 “Semantic versioning is a standard that a lot of projects use to communicate what kinds of changes are in this release. It's important to communicate what kinds of changes are in a release because sometimes those changes will break the code that depends on the package.” - NPM
  • 26. Use the correct versioning to ensure compatibility for your users. Versioning 26 • 1.0.0 - Publish to NPM.  npm publish • 1.0.1 - Patch release. Bug fixes or minor changes.  npm version patch -m “[B124] Fixes some bug” • 1.1.0 - Minor release. New feature with backwards compatibility.  npm version minor -m “Adds X feature” • 2.0.0 - Major release. New features that break old versions.  npm version major -m “Architecture change for X”
  • 27. Let’s check out the demo! 27
  • 28. react-image-layout 28  Lightweight  Encapsulated  Stateless (if possible)  Performant  Minimal  PropTypes + DefaultProps  Tests (UI + unit)  Linters  README (pictures, props, tips)  Example Usage  Package.json

Hinweis der Redaktion

  1. React brought a new dynamic standard to web apps
  2. - Pinit, Follow, Pin, Board, Profile, Grid
  3. - VirtualDOM is cool, but components are better - Field defined by an ecosystem of collaboration - Let better people build better things
  4. Lightweight: good developers are aware of the weight of a dependency. Keep yours light to encourage usage. Lodash vs Underscore. Encapsulated: important for open-source components Stateless: great, but encapsulated components tend to have state, that’s ok! Performant: in an ecosystem with multiple alternatives, be the fastest Minimal Dependencies: pubsub libraries, query string libraries, try to avoid all dependencies
  5. Test the notes
  6. Test the notes
  7. Test the notes
  8. - Engineers are notoriously bad at documentation, but for open-source, it is absolutely essential.
  9. Test the notes
  10. - Apache (Android, Swift), GPL (Linux, Wordpress)
  11. Test the notes
  12. Test the notes
  13. Test the notes