[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 ...
随机推荐
- tomcat启动时报No rules found matching 'Server/Service/Engine/Host/context'
tomcat是8.0版本. 在eclipse启动时,第二行报这个, 同时项目也没加载(tomcat启动成功了). 网上搜了半天, 试了半天, 没搞定. 最后不经意间发现: <Context do ...
- C++静态库与动态库的区别
在日常开发中,其实大部分时间我们都会和第三方库或系统库打交道.在 Android 开发音视频开发领域,一般会用到 FFmepg.OpenCV.OpenGL 等等开源库, 我们一般都会编译成动态库共我们 ...
- day50——js补充
day50 前端内容回顾 HTML 标签分类 块级标签:div p h1-h6 form hr br ul li ol table标签 内联标签:span a img label input sele ...
- MacBook Pro配置汇编开发环境
配置开发环境 方法一: 打开命令行,输入指令which nasm查看nasm的安装路径,Mac系统默认安装了nasm.一般默认返回的路径是/usr/bin/nasm 接着输入指令alias nasm= ...
- 「UER#2」谣言的传播
「UER#2」谣言的传播 写了个乱搞,怎么莫名其妙就AC了,这...,之后又想了30min结合题解终于会证了. 首先最大值比较简单,记 \(f_i\) 为第 \(i\) 个点能到达的点数,上界 \(\ ...
- Java 阿拉伯数字转换为中文大写数字
Java 阿拉伯数字转换为中文大写数字 /** * <html> * <body> * <P> Copyright 1994 JsonInternational&l ...
- Java自学-操作符 位操作符
Java的位操作符 位操作符 在实际工作中使用并不常见. 示例 1 : 一个整数的二进制表达 位操作都是对二进制而言的,但是我们平常使用的都是十进制比如5. 而5的二进制是101. 所以在开始学习之前 ...
- 科普帖:Linux操作系统
使用计算机必然会接触操作系统,现代操作系统已经发展的十分成熟,一般用户都可以很轻松的使用计算机.然而,对于要利用计算机进行专业开发和应用的用户来说,需要更加深入地理解操作系统的原理和运行机制,这样才能 ...
- AVI文件格式
AVI文件采用的是RIFF文件结构方式.波形音频wave,MIDI和数字视频AVI都采用这种格式存储. AVI文件的整体结构如下图所示 构造RIFF文件的基本单元叫做数据块(Chunk),每个数据块包 ...
- npm和Node.js简介
Node.js Node.js是JavaScript的一种运行环境,是对Google V8引擎进行的封装.是一个服务器端的javascript的解释器.Node.js允许通过JavaScript和一系 ...