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的更多相关文章

  1. [React] Write a Custom React Effect Hook

    Similar to writing a custom State Hook, we’ll write our own Effect Hook called useStarWarsQuote, whi ...

  2. [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 ...

  3. 【React 资料备份】React Hook

    Hooks是React16.8一个新增项,是我们可以不用创建class组件就能使用状态和其他React特性 准备工作 升级react.react-dom npm i react react-dom - ...

  4. [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 ...

  5. React报错之React Hook 'useEffect' is called in function

    正文从这开始~ 总览 为了解决错误"React Hook 'useEffect' is called in function that is neither a React function ...

  6. React报错之React hook 'useState' cannot be called in a class component

    正文从这开始~ 总览 当我们尝试在类组件中使用useState 钩子时,会产生"React hook 'useState' cannot be called in a class compo ...

  7. [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 ...

  8. React报错之React Hook useEffect has a missing dependency

    正文从这开始~ 总览 当useEffect钩子使用了一个我们没有包含在其依赖数组中的变量或函数时,会产生"React Hook useEffect has a missing depende ...

  9. React报错之React hook 'useState' is called conditionally

    正文从这开始~ 总览 当我们有条件地使用useState钩子时,或者在一个可能有返回值的条件之后,会产生"React hook 'useState' is called conditiona ...

随机推荐

  1. UML交互图

    UML 交互图主要包括对象和消息两类元素,创建交互图的过程实际上就是向对象分配任务的过程,是可视化系统的交互行为. UML 交互图包括两种:序列图和协作图. 序列图:显示对象之间的关系,强调对象之间消 ...

  2. Python之路【第二十六篇】:HTTP协议

    HTTP协议 一.HTTP概述 HTTP(hypertext transport protocol),即超文本传输协议.这个协议详细规定了浏览器和万维网服务器之间互相通信的规则. HTTP就是通信规则 ...

  3. redis源码分析(二)-rio(读写抽象层)

    Redis io抽象层 Redis中涉及到多种io,如socket与file,为了统一对它们的操作,redis设计了一个抽象层,即rio,使用rio可以实现将数据写入到不同的底层io,但是接口相同.r ...

  4. Scala 安装 Scala for Eclipse安装及运行hello word

    Scala下载安装地址:https://www.scala-lang.org/download/ .windows版本的安装包是scala-2.12.8.msi.直接滑动到网页最下面,下载对应的系统的 ...

  5. FMX 窗口置顶 或置底 xe10

    FMX 窗口置顶  或置底 xe10 Popup 置底 StayOnTop 置顶

  6. jquery跨js文件调用函数示例

    var common_func; (function() { common_func = { load_hot_data: function(AreaCode) { var hot_html = &q ...

  7. AS shortcuts

    stl => statelessstf => statefulalt+enter, select element => add pading or somethingselect c ...

  8. 【转载】C#中Convert.ToDouble方法将字符串转换为double类型

    在C#编程过程中,可以使用Convert.ToDouble方法将字符串或者其他可转换为数字的对象变量转换为double类型,Convert.ToDouble方法有多个重载方法,最常使用的一个方法将字符 ...

  9. html 随机验证码

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. js中console.info的使用

    语法:console.info(obj1 [, obj2, ..., objN]);console.info(msg [, subst1, ..., substN]); 参数obj1 ... objN ...