[NPM + React] Prepare a Custom React Hook to be Published as an npm Package
Before we publish our package, we want to make sure everything is set up correctly. We’ll cover versioning, preparing our package, adding a proper README, and updating our package.json
.
Using npm version:
The reason to use npm version to prumping the version, is because it create a version commit and tag.
npm version patch
Setup a pre- and post- scripts:
"prepare": "yarn run build",
"postpublilsh": "git push --tags"
peerDependenices:
You might also need to update peerDependencies in order to info the user which verison of react is minimue required.
"peerDependencies": {
"react": ">=16.8.6"
}
publishConfig:
Depend on your package name:
// A
"name": "some-react-hooks" //B
"name": "@zhentiw/some-react-hooks" //@<user-name>/package-name
If you are using B version, it default to a private npm package, if you want to make it public:
"publishConfig": {
"access": "public"
}
[NPM + React] Prepare a Custom React Hook to be Published as an npm Package的更多相关文章
- [React] Write a Custom React Effect Hook
Similar to writing a custom State Hook, we’ll write our own Effect Hook called useStarWarsQuote, whi ...
- [React] Write a Custom State Hook in React
Writing your own custom State Hook is not as a daunting as you think. To keep things simple, we'll r ...
- 【React 资料备份】React Hook
Hooks是React16.8一个新增项,是我们可以不用创建class组件就能使用状态和其他React特性 准备工作 升级react.react-dom npm i react react-dom - ...
- [React] Reduce Code Redundancy with Custom React Hooks
In this lesson, we'll cover how to create a custom React hook for managing the state of any input. T ...
- React报错之React Hook 'useEffect' is called in function
正文从这开始~ 总览 为了解决错误"React Hook 'useEffect' is called in function that is neither a React function ...
- React报错之React hook 'useState' cannot be called in a class component
正文从这开始~ 总览 当我们尝试在类组件中使用useState 钩子时,会产生"React hook 'useState' cannot be called in a class compo ...
- [React] Validate Custom React Component Props with PropTypes
In this lesson we'll learn about how you can use the prop-types module to validate a custom React co ...
- React报错之React Hook useEffect has a missing dependency
正文从这开始~ 总览 当useEffect钩子使用了一个我们没有包含在其依赖数组中的变量或函数时,会产生"React Hook useEffect has a missing depende ...
- React报错之React hook 'useState' is called conditionally
正文从这开始~ 总览 当我们有条件地使用useState钩子时,或者在一个可能有返回值的条件之后,会产生"React hook 'useState' is called conditiona ...
随机推荐
- Django框架(十二)-- 中间件、CSRF跨站请求伪造
中间件 一.什么是中间件 请求的时候需要先经过中间件才能到达django后端(urls,views,templates,models) 响应的时候也需要经过中间件才能到达web服务网关接口 djang ...
- 深度学习-Wasserstein GAN论文理解笔记
GAN存在问题 训练困难,G和D多次尝试没有稳定性,Loss无法知道能否优化,生成样本单一,改进方案靠暴力尝试 WGAN GAN的Loss函数选择不合适,使模型容易面临梯度消失,梯度不稳定,优化目标不 ...
- 【SpringBoot】SpingBoot整合AOP
https://blog.csdn.net/lmb55/article/details/82470388 [SpringBoot]SpingBoot整合AOPhttps://blog.csdn.net ...
- Windows 上的应用程序在运行期间可以给自己改名(可以做 OTA 自我更新)
原文:Windows 上的应用程序在运行期间可以给自己改名(可以做 OTA 自我更新) 程序如何自己更新自己呢?你可能会想到启动一个新的程序或者脚本来更新自己.然而 Windows 操作系统允许一个应 ...
- Go defer 会有性能损耗,尽量不要用?
上个月在 @polaris @轩脉刃 的全栈技术群里看到一个小伙伴问 “说 defer 在栈退出时执行,会有性能损耗,尽量不要用,这个怎么解?”. 恰好前段时间写了一篇 <深入理解 Go def ...
- CSS揭秘(引言)
1.标准的制定过程 a 人员结构:W3C会员公司的成员.特邀专家.W3C工作人员 b 尽管“CSS3”非常流行,但它实际上并没有在任何规范中定义过.它实际上是指一个非正式的集合,包括CSS规范第三版再 ...
- Node和浏览器端所支持的模块规范不同
- js 数据类型检测
提起数据类型检测 大多数人首先想起的应该是 typeof 'xxx' == '数据类型' 坦然这种方法对于基本数据类型的检测还是非常方便的,但是当遇到引用数据类型 Object时却爱莫能助,下面就 ...
- JQuery+Bootstrap 自定义全屏Loading插件
/** * 自定义Loading插件 * @param {Object} config * { * content[加载显示文本], * time[自动关闭等待时间(ms)] * } * @param ...
- DataPipeline如何实现数据质量管理?
数据质量管理已经成为数据治理的重要组成部分.高质量的数据是企业进行决策的重要依据. DataPipeline数据质量平台整合了数据质量分析.质量校验.质量监控等多方面特性, 以保证数据质量的完整性.一 ...