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

findDOMNode is deprecated in StrictMode #257

Closed
DatStorm opened this issue Apr 27, 2020 · 11 comments
Closed

findDOMNode is deprecated in StrictMode #257

DatStorm opened this issue Apr 27, 2020 · 11 comments

Comments

@DatStorm
Copy link

Try to use notistack in functional component.

Expected Behavior

Should now throw a warning.

Current Behavior

React.strictmode creates warning

Steps to Reproduce

import React from 'react';
import { Button } from '@material-ui/core';
import { withSnackbar } from 'notistack';

const Home = (props) => {
	const handleClick = () => {
		props.enqueueSnackbar('Successfully fetched the data.');
	};

	const classes = useStyles();
	return (
		<div>
			<Button onClick={handleClick}>Test</Button>
		</div>
	);
};

export default withSnackbar(Home);

Versions:

"react": "^16.13.1",
"react-dom": "^16.13.1",
notistack": "^0.9.11",
"pondjs": "^0.9.0",

to me

Let me know if I need to provide more info.

@stevenkitter
Copy link

the same question

@JoaoHenriqueBarbosa
Copy link

Same here

1 similar comment
@ihormaslov
Copy link

Same here

@iamhosseindhv
Copy link
Owner

Seems to be working here: https://codesandbox.io/s/delicate-hill-p25hr

Unfortunately without a reproduction example I'm unable to help.

@DatStorm
Copy link
Author

DatStorm commented May 4, 2020

I can reproduce it here in your example: https://codesandbox.io/s/eager-haze-fkn0w?file=/index.js

otherwise chagne index.jsx render to:

ReactDOM.render(
  <React.StrictMode>
    <SnackbarProvider maxSnack={3}>
      <App />
    </SnackbarProvider>
  </React.StrictMode>,
  document.getElementById("root")
);

Hope this helps :)

@iamhosseindhv
Copy link
Owner

I see the warning now. If anything this is an issue with @material-ui/core or react-transition-group.

Many thanks.

@davehowson
Copy link

Is there any solution to this besides disabling Strict Mode?

@heybenchen
Copy link

For anyone using MaterialUI, I got around this by wrapping the ThemeProvider around SnackbarProvider:

  <React.StrictMode>
    <ThemeProvider theme={theme}>
      <SnackbarProvider maxSnack={3}>
        <App />
      </SnackbarProvider>
    </ThemeProvider>
  </React.StrictMode>,

@ujnimz
Copy link

ujnimz commented Jan 26, 2021

I am using MaterialUI, The warning is still there after wrapping the ThemeProvider around SnackbarProvider. This is also advised on official documentation.

Note: If you're using material-ui ThemeProvider, make sure SnackbarProvider is a child of it.

@manoharreddyporeddy
Copy link

A solution is here - https://stackoverflow.com/a/66290597/984471

@drnguyenn
Copy link

This is an issue of MaterialUI library, and there's a temporary solution here before the new MaterialUI v5 is officially released.

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

10 participants