How To Publish React Hooks And Components As NPM Package? A Beginner's Guide #react #rollup #npm

How To Publish React Hooks And Components As NPM Package? A Beginner's Guide #react #rollup #npm

tapaScript by Tapas Adhikary

6 месяцев назад

5,077 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@abdurrahman720
@abdurrahman720 - 26.02.2024 02:45

getting error for react component

Ответить
@sanjuwa2677
@sanjuwa2677 - 23.02.2024 17:59

learned about rollup. Thanks

Ответить
@aakashvishwakarma2243
@aakashvishwakarma2243 - 18.01.2024 19:07

Hey Tapas,
this is my hook
import React from "react";
import { useRef } from "react";
import { useState } from "react";

const useHalfClicked = () => {
const [halfClicked, setHalfClicked] = useState();
const divRef = useRef();

const handlHalfClicked = (e) => {
const divWidth = divRef.current.getBoundingClientRect().width;
const halfDivWidth = divWidth / 2;
const mouseXPos = e.nativeEvent.offsetX;
const half = mouseXPos <= halfDivWidth;
setHalfClicked(half);
};

const HalfWrapper = ({ children }) => {
return (
<div
style={{ width: "fit-content" }}
ref={divRef}
onClick={handlHalfClicked}
>
{children}
</div>
);
};

return {
halfClicked,
HalfWrapper,
};
};

export default useHalfClicked;
I am getting below error
[!] RollupError: Expression expected
src/hooks/useHalfClicked.js (19:6)
17: const HalfWrapper = ({ children }) => {
18: return (
19: <div
^
20: style={{ width: "fit-content" }}
21: ref={divRef}
at error (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\parseAst.js:279:30)
at nodeConverters (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\parseAst.js:2147:9)
at convertNode (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\parseAst.js:1032:12)
at convertProgram (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\parseAst.js:1023:48)
at Object.parseAstAsync (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\parseAst.js:2213:20)
at Module.tryParseAsync (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\rollup.js:14942:20)
at Module.setSource (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\rollup.js:14523:35)
at ModuleLoader.addModuleSource (E:\react\npmPackages\aakash-hooks\node_modules\rollup\dist\shared\rollup.js:18860:13)

Ответить
@aakashvishwakarma2243
@aakashvishwakarma2243 - 17.01.2024 21:53

Great video

Ответить
@AkonMHasib_Official
@AkonMHasib_Official - 24.12.2023 13:25

❤❤❤❤❤❤❤❤

Ответить
@msi313
@msi313 - 17.12.2023 03:58

ধন্যবাদ,
ভালভাবে বুঝতে পারলাম। ❤

সরাসরি GitHub থেকে publish করার ভিডিও চাই ❤

Ответить
@codingzen869
@codingzen869 - 16.12.2023 22:14

Why don't you make an actually useful and robust package explaining the architecture, code structure etc? Not like a big one, a medium sized one. That will be really great. Everybody shows the flow, but few shows building the real deal. Please do one.

Ответить
@injamamislamchowdhury7939
@injamamislamchowdhury7939 - 16.12.2023 21:12

awesome! really thanks for your dedication. if i want to publish any react component, will it be same proccedure as you have guided here?

Ответить
@OjitDebNath
@OjitDebNath - 16.12.2023 17:13

Really awesome video and we want next video about rollup. Thank you❤

Ответить
@farhadjaman5580
@farhadjaman5580 - 16.12.2023 14:19

thank you for this amazing video sir.

Ответить
@Anguraj92
@Anguraj92 - 16.12.2023 14:08

Thank you

Ответить
@ArifeenSifat
@ArifeenSifat - 16.12.2023 13:56

really helpful video .
Thanks for sharing with us❤❤

Ответить