-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
TS Error: SnackbarProvider cannot be used as a JSX component #485
Comments
Same here with |
Same here with |
I was getting this same compile error I updated my @types/react to 18.0.8 and I am no longer getting the compilation error. |
I solved by setting in package.json
|
It works with that config. Thank you! 🙏 |
Thanks for reporting and I'm glad there's some solution for this. I've been unable to reproduce, so if you could provide one, I'll reopen this issue. |
As mentioned above, I'd need a reproduction sandbox to investigate this |
Same error |
Same error with:
Adding the suggested FWIW this was never working for me, I just tried adding notistack to my app Today. I also just tried replicating in Codesandbox but it was struggling to find react-dom 17.0.2 so I didn't get anywhere. If I manually patch |
I am currently facing the same issue using react 17.0.2. I have tried to reproduce it in CodeSandbox but the issue didn't appear there! From my small investigation it seems like the issue is For the quick patch you can create a import { SnackbarProvider as SnackbarProviderBase } from 'notistack';
declare module 'notistack' {
export interface SnackbarProvider extends SnackbarProviderBase {
render(): ReactNode;
}
} P.S. I believe CodeSandbox uses |
I can confirm my affected project uses |
also using i was able to fix the issue by making sure the following packages were aligned:
all set to version i also created the file and as if by magic, the issue resolved. not sure if this is the preferred solution but it worked for me, for now. |
that does nothing but override the type declaration of notistack with an empty one. The real fix is highlighted by @hangaoke1 above -- which is something you can do in your local |
Any update for when this will be fixed? |
I also need a fix for this. Following! |
For Typescript and React users, a possible solution: import providers, { Provide } from 'react-manage-providers'
import { SnackbarProvider } from 'notistack'
import { SNACKBAR_OPTIONS, QUERY_CLIENT_OPTIONS, QueryClientProvider } from '@company/utils-general'
providers.push(SnackbarProvider, SNACKBAR_OPTIONS)
providers.push(QueryClientProvider, QUERY_CLIENT_OPTIONS)
export const MasterProvider = Provide export const App = () => (
<MasterProvider>
<CssBaseline />
<BrowserRouter>
<RootRouter />
</BrowserRouter>
</MasterProvider>
) |
I'm using:
Downgrading to
and deleting my |
The fix for this is published as |
Just updated to 2.0.7 and getting some new errors:
Resolved dependencies:
|
First error is because this line references a nonexistant import: Line 267 in 9ec749b
This should be |
And the second type |
PR to fix: #520 |
The fix is published as |
Should this fix resolve the issue for React 17, or just React 18? I'm running 17.0.2 and still seeing this on Notistack 2.0.8:
|
I'm also having this issue on React 17.0.1 (environment on this project does not allow higher than 17.0.1) |
Please upgrade React to 17.0.2 add package.json:
|
Im having the same issue after updating to I had to just just ignore the ts error
Has anyone found a solution to this? |
yeah this isnt fixed in React 17.02 and notistack 2.0.8 using yarn at least |
so the solution seems to be update to latest notistack 2.0.8
even if you leave these at 17
|
Saved my life. Thank you. |
We're having the same issue here as well... "notistack": "3.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"@types/react": "18.2.6",
"@types/react-dom": "18.2.4",
"packageManager": "yarn@3.4.1" Is there a fix for this yet? |
This still happens. |
Just encountered this with:
|
In my case, it was fixed by deleting yarn.lock and doing |
I am getting this issue as well. I tried the @bibixx solution but unfortunately, it's not working for me. |
Any help would definitely be appreciated in this. My dependencies:
|
Same issue here:
Note: I'm using npm v9.8.0 |
I don't know what the maintainers are looking at. They should've merged
this PR since. It's been 2 weeks now
…On Mon, Sep 4, 2023, 7:30 AM Amir Mohammad Moradi ***@***.***> wrote:
Same issue here:
***@***.***/react": "^18.2.12",
***@***.***/react-dom": "^18.2.5",
"notistack": "3.0.1",
—
Reply to this email directly, view it on GitHub
<#485 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3XNHCCVDO3L5A5H4UN7SNDXYVYRTANCNFSM5UPB6YGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I could fix the issue for my case in a bit different way: import { Component, ReactNode } from 'react';
import { SnackbarProviderProps } from 'notistack';
declare module 'notistack' {
export interface SnackbarProvider extends Component<SnackbarProviderProps> {
render(): ReactNode;
}
} |
Seems there is a conflict in types between
@types
versions used. I use"@types/react": "^18.0.8"
and"@types/react-dom": "^18.0.0"
while notistack and/or mui use"@types/react": "^16.8.6 || ^17.0.0"
or"@types/react": "^16.9.23"
Expected Behavior
No compiler error
Current Behavior
Compiler error:
Steps to Reproduce
Link:
Context
Your Environment
The text was updated successfully, but these errors were encountered: