Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call hook outside react context #44

Open
fijemax opened this issue Mar 16, 2021 · 4 comments
Open

Call hook outside react context #44

fijemax opened this issue Mar 16, 2021 · 4 comments

Comments

@fijemax
Copy link

fijemax commented Mar 16, 2021

Hello,

I used react-top-loading-bar in a simple way in a component library:

      <LoadingBar
        shadow={false}
        progress={missionsDownloadProgress}
        height={3}
        color='#00AAC2'
      />

So when I link the library to my application, I have a hook problem:
image

I inspected hook in react-top-loading-bar code and didn't find anything ... but in the file index.modern.js from npmjs package I found this:
image
and it seems corrrspond to this code:
image

To summaries:
Object(__WEBPACK_IMPORTED_MODULE_0_react__["useRef"]) => checkIfFull

I deleted the index.modern.js" frile from the node_module package react-top-loading-barand webpack usedindex.jsfile instead, and seems work perfectly. But I don't know how to configure webpack to useindex.jsinstead ofindex.modern.jsand I don't know ifindex.modern.js``` is generated correctly.

@klendi
Copy link
Owner

klendi commented Mar 16, 2021

Interesting, this never occurred to me before.
Why don't you use onLoaderFinished(), to reset the progress. <LoadingBar color="#f11946" progress={progress} onLoaderFinished={() => setProgress(0)} />
Can you share more details on how can I reproduce this, react version, are you using next / cra / gatsby, etc. Also is it just a warning or does it crash ?

@fijemax
Copy link
Author

fijemax commented Mar 16, 2021

I tryed with the onLoader FInished callback prop but I got the same problem.
What i find weird that is seem normal that index.modern.js crash by seeing the code, no ?
It's a crash, but it seem appear in a timeout callback (which would seem logical given the hook react context error), but we have many sentry about it.

@fijemax
Copy link
Author

fijemax commented Mar 16, 2021

we are using "react": "^16.8.2"

@khooz
Copy link

khooz commented Jun 7, 2021

@fijemax Is this still an issue? Can you please provide a self contained reproducible example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants