SlideShare a Scribd company logo
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

More Related Content

What's hot

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
Pablo Godel
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
John Anderson
 
Javascript test frameworks
Javascript test frameworksJavascript test frameworks
Javascript test frameworks
talkitbr
 
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
Gavin Pickin
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
Ahmed AbouZaid
 
Ansible, Idempotency, and Jenkins
Ansible, Idempotency, and JenkinsAnsible, Idempotency, and Jenkins
Ansible, Idempotency, and Jenkins
tylerturk
 
[123] quality without qa
[123] quality without qa[123] quality without qa
[123] quality without qa
NAVER D2
 
Testing Automaton - CFSummit 2016
Testing Automaton - CFSummit 2016Testing Automaton - CFSummit 2016
Testing Automaton - CFSummit 2016
Ortus Solutions, Corp
 
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
Daniel Garcia (a.k.a cr0hn)
 
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
Daniel Garcia (a.k.a cr0hn)
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
Viresh 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 Wood
Ortus 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 Apps
Pablo Godel
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chef
ice799
 
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
Giorgio 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 Infrastructure
Yury Tsarev
 
CommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementCommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package Management
Ortus Solutions, Corp
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous Integration
Michael Peters
 

What's hot (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
 

Similar to Building Open-source React Components

Getting Started with Node.js
Getting Started with Node.jsGetting Started with Node.js
Getting Started with Node.js
Justin Reock
 
Nodeconf npm 2011
Nodeconf npm 2011Nodeconf npm 2011
Nodeconf npm 2011
Florent Jaby ヅ
 
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
 
Cypress for Testing
Cypress for TestingCypress for Testing
Cypress for Testing
PoojaSingh1123
 
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
Jürgen Gutsch
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
Robert Lujo
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
Stanislav Petrov
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
Jacob 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 Code
Kris 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.js
Sebastian 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 Kharvi
Cysinfo 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.js
Chetan Desai
 
Devops
DevopsDevops
Devops
JyothirmaiG4
 
2014 land your-first_patch_neutron
2014 land your-first_patch_neutron2014 land your-first_patch_neutron
2014 land your-first_patch_neutron
Rossella Sblendido
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
Virtual JBoss User Group
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
Jeffery Smith
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
GlobalLogic Ukraine
 
Android lint presentation
Android lint presentationAndroid lint presentation
Android lint presentation
Sinan KOZAK
 

Similar to 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
 

Recently uploaded

在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 

Recently uploaded (20)

在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 

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

Editor's Notes

  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