react-singleton-hook:从常规React钩子创建单例钩子

时间:2021-07-23 14:11:11
【文件属性】:
文件名称:react-singleton-hook:从常规React钩子创建单例钩子
文件大小:171KB
文件格式:ZIP
更新时间:2021-07-23 14:11:11
react state-management hooks-api-react JavaScript React单例钩子 使用钩子管理 React 应用程序的全局状态。 安装 要在 React 应用程序中使用 React Singleton Hook,请将其安装为依赖项: # If you use npm: npm install react-singleton-hook # Or if you use Yarn: yarn add react-singleton-hook 这假设您将包管理器与模块捆绑器(如或一起使用来使用。 什么是单例钩子 单例钩子在功能方面与 React Context 非常相似。 每个单例钩子都有一个主体,您可以将其视为 Context Provider 主体。 Hook 有一个返回值,它类似于 context 提供的值。 使用组件中的单例钩子就像使用上下文一样。 单例钩子是懒惰的。 在某个组件或其他钩子调用钩子之前,不会执行主体。 一旦加载,钩体将永远保持
【文件预览】:
react-singleton-hook-master
----.circleci()
--------config.yml(872B)
----.gitignore(35B)
----README.md(10KB)
----rollup.config.js(1KB)
----test()
--------components()
--------integration()
--------react-native()
----.babelrc.js(396B)
----package.json(3KB)
----src()
--------components()
--------utils()
--------index.js(297B)
--------singletonHook.js(1KB)
----CODE_OF_CONDUCT.md(3KB)
----LICENSE.md(1KB)
----.tool-versions(15B)
----jest.config.js(900B)
----index.d.ts(280B)
----.eslintignore(13B)
----yarn.lock(394KB)
----.eslintrc.js(7KB)
----.dependabot()
--------config.yml(108B)

网友评论