Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

自定义React Hooks如何封装成npm包

按照npm创建的模板,在index.js引入hooks文件并导出,因为我写的hooks引入了antd组件,导致安装使用时会报错,好像是编译问题,有什么好的教程可以配一个模板项目。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

最好不要依赖第三方库,否则打包的时候不好处理。可以参考我的一篇文章https://johnsonlee.site/post/develop-a-library-based-typescript/,
以及我封装的Vue hooks库https://johnsonlee.site/post/vue-composition-api-first-sight/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...