JS.weekly() => #47: The 10 Component Commandments
Reusable UI components in React, moving to lerna-js mono-repo and Verly.js.
In this post, the author will suggest some principles, methods, and tools that can help your team share and reuse your components to build new apps faster.
“ At mitter.io, we have a couple of public-facing
npm packages that we need to publish, and we recently moved to a mono-repo structure managed by Lerna from having separate repositories for each one of them. Today, I’d like to share our experience of this migration and our setup with the new monorepo structure.”
- Document the usage
- Allow for contextual semantics
- Avoid boolean props
- Use props.children
- Let the parent hook into internal logic
- Spread the remaining props
- Give sufficient defaults
- Don't rename HTML attributes
- Write prop types (or types)
- Desingn for the developers