Create an NPM Package from a React Component

preview_player
Показать описание
In this tutorial, I explain how to set up Webpack and Babel to create an npm package with a react component inside.
Also, it demonstrates how to avoid "Hooks can only be called inside the body of a function component" error.

If it doesn't work for you:
#1: Maybe you should re-run `npm start` to make it work.
#3: Don't forget to increment the version if you publish again

Рекомендации по теме
Комментарии
Автор

Dude, it was fast, clean and to-the-point! thanks!

ArdyAryan
Автор

I have love for your skills brother... hope you continue making helpful videos like this! You got a new subscriber :)

Ali-mcle
Автор

Thanks you so much for this tutorial man. I'm still really new to react and npm, so I mostly followed along. I still need to study this stuff in depth, but with your help, I was able to publish my first useful npm package!
Thanks again from your 18th subscriber. 😉👍

yitzchaksviridyuk
Автор

Thankyou! Amazing and short video!
It worked! I followed all the steps and I published some react components.

josemanuelserranoamaut
Автор

Hey, Thanks for the tutorial. Straight forward and quick!

damnitrahul
Автор

Very helpful content and your skills are superb Yurko.New Subscriber

muhammadbilal
Автор

I faced a small error. Had to include peerDepedencies in modules package.json file.

"peerDependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},

yt_amarjit
Автор

Thank you dude!!! from Hyderabad, India. God Bless you

kmeeraj
Автор

Hey Yurko, ty for the video!
Can you pls explain why do we have to link react from application/node_modules and is there any way to avoid it?

wadewilson
Автор

Hi,
I love your approach but your application also taking package from artifactory not from local folder
its not working at all

narayankushwah
Автор

Great tutorial man, Thanks it helped me alot.

harshthosar
Автор

thanks my brother! this help me a lot!!!

Bostathelink
Автор

Thank You So much...Really helped a lot

rutwikwaghmare
Автор

Can I do this with whole react app (App.js) and its components and dependencies?

dd
Автор

I do react but I still don't know babel and webpack. do we need them to create an package

craftzki
Автор

Is there a particular order that needs to be followed when executing these commands? Because, I tried the same, but i am getting "Invalid Hook Error"

ujjavalsinha
Автор

thanks alot this was really helpful :)

zrebrutibreniti
Автор

I am getting error : Uncaught ReferenceError: React is not defined. What to do in such case?

balledachandrahas
Автор

how can i do to fix this error

Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.

Hash: ddf76ea2ba092b265664
Version: webpack 4.44.1
Time: 70ms
Built at: 09/04/2020 8:06:38 PM

ERROR in Entry module not found: Error: Can't resolve 'babel-loader'

hamidpinilla
Автор

What if there is Java code for native Android component? How do we include Java code into npm package too? I meant in React Native, not simply React.

vic