Crafting Reusable Code with React & TypeScript: From Design to npm
Recycle Reuse Reduce
My name is Dennis.
A typescript enjoyer
Table of contents
01
Simple component
02
Simple but dynamic
03
Generic version of the component
04
Component as a package
Why typescript?
Cons : tsconfig hell
> Suggestion : when possible use deno/bun
Cons : build step
> Suggestion : ignore dhh we all know js > ruby
Cons : speed of tsc
> Suggestion : pray microsoft cares enough to rewrite it in something faster
Pros
Why NPM?
01
Simple component
observation:
> The rows can be dynamic
02
Dynamic component
Dynamic rows
observation:
> The columns can be dynamic
Dynamic rows and columns
observation:
> The columns can be passed in from the outside allowing the component to take in any array and render it’s contents
03
Generic component
Generic component
Generic component
04
Packaging
tsconfig
Package json
tsup config
versioning
namespaces
When you sign up for an npm user account or create an organization, you are granted a scope that matches your user or organization name. You can use this scope as a namespace for related packages
Popular examples include @types/ which is used to publish dts declarations for libraries that didn’t ship their own types
"publishConfig": {
"access": "public"
}
Publish steps
"publishConfig": {
"access": "public"
}
Final steps
Thank you for playing your part
React is awesome, Thank you 😊
@tigawanna