[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 ...
随机推荐
- 10步成为一个优秀的Java开发!
1.拥有坚实的基础并理解面向对象原则 Java开发人员必须深刻理解面向对象编程.如果没有面向对象编程的坚实基础,就无法感受到像Java这样的面向对象编程语言的美感. 如果你不太了解现象对象编程是什么, ...
- C语言:求π
1835: 圆的面积 本题的关键在于如何求π: 今天先给给大家介绍一种针对本题的方法——利用反三角函数求π. 在高数中arcsin(0)=arccos(1)=π,不过编译器中并没有arcsin和arc ...
- 安装macOS时遇到Unable to unmount volume for repair异常导致无法完成安装的解决办法
方法一: 使用终端命令行制作完macos安装U盘后,务必将.IAProductInfo文件放到U盘的根目录(非EFI分区的) sudo /Applications/Install\ macOS\ Si ...
- 【题解】Luogu P5283 [十二省联考2019]异或粽子
原题传送门 看见一段的异或和不难想到要做异或前缀和\(s\) 我们便将问题转化成:给定\(n\)个数,求异或值最靠前的\(k\)对之和 我们珂以建一个可持久化01trie,这样我们就珂以求出每个值\( ...
- 【1】TOPK最小的K个数(多种方法比较)
(头条) 最小的第K个数也是和这题topK一样的思路 1.全排序 时间复杂度O(nlogn) 2.Partiton思想 时间复杂度O(n) (因为不需要像快排一样对所有的分段都两两Partitio ...
- 百度搜索常用api
http://www.baidu.com/s?wd=关键字 wd(Keyword):查询的关键词:http://www.baidu.com/s?wd=关键字&cl=3 cl(Class):搜索 ...
- sping boot/cloud配置文件 on 读取为true
sping boot/cloud配置文件 on 读取为true 原文地址:https://blog.csdn.net/hb9176070/article/details/82749771 最近在写sp ...
- Oracle PLSQL数据导出csv的案例
之前项目运维人员碰到一个问题,需要写一个存储过程,把数据导出为csv文件,查了一些资料,帮他写成了一个PLSQL,今天拿出来分享一下,不足之处,欢迎指教. 数据背景: 用到两张表,一张存放单位组织名 ...
- 个人项目(JAVA实现)
一:Github项目地址:https://github.com/candy07213/WC 二:PSP表格 PSP2.1 Personal Software Process Stages 预估耗时(分 ...
- Linux操作系统的进程管理和作业管理
Linux操作系统的进程管理和信号 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.lsof命令详解 1>.lsof概述 list open files查看当前系统文件的工 ...