bug: deprecated findDOMNode usage with React.StrictMode
See original GitHub issueBug Report
Ionic version: [x] 4.x “@ionic/react”: “^5.0.7”
Current behavior:
I am trying to install Ionic React to a fresh create-react-app but hit the error
findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of IonComponent which is inside StrictMode quite a lot. I notice that if I create the app with
ionic start
, it won’t notice because the<App />
component is not wrapped insideReact.StrictMode
. Does that mean that you guys don’t support StrictMode right now, what is the plan for Ion components to work withStrictMode
?
Expected behavior:
Avoid using findDOMNode
to refer to an element, hence not getting this error on React Strict mode
Steps to reproduce:
- Create a React app with
create-react-app
- Make sure
<App />
component is wrapped insideReact.StrictMode
- Create a component with
IonReactRouter
import React, { FC } from 'react';
import { IonApp, IonRouterOutlet } from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router';
import { Redirect, Route } from 'react-router-dom';
import { Home } from './pages/home';
import { About } from './pages/about';
import { Error } from './pages/error';
export const Router: FC = ({ children }) => (
<IonApp>
<IonReactRouter>
<IonRouterOutlet>
<Route path="/" exact component={Home} />
<Route path="/about" exact component={About} />
<Route path="/404" exact component={Error} />
<Route path="/contact" render={() => <Redirect to="/error" />} exact={true} />
</IonRouterOutlet>
{children}
</IonReactRouter>
</IonApp>
);
or
import React from 'react';
import { IonTabBar, IonIcon, IonLabel, IonTabButton } from '@ionic/react';
import { home, callOutline, informationCircleOutline } from 'ionicons/icons';
export const Tabbar = () => (
<IonTabBar slot="bottom">
<IonTabButton tab="home" href="/home">
<IonIcon icon={home} />
<IonLabel>Home</IonLabel>
</IonTabButton>
<IonTabButton tab="about" href="/about">
<IonIcon icon={informationCircleOutline} />
<IonLabel>About</IonLabel>
</IonTabButton>
<IonTabButton tab="contact" href="/contact">
<IonIcon icon={callOutline} />
<IonLabel>Contact</IonLabel>
</IonTabButton>
</IonTabBar>
);
- Run
yarn start
- Check browser console
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Warning: findDOMNode is deprecated in StrictMode ...
If you're using a Modal or Carousel from react-bootstrap a workaround is disabling the animations.
Read more >React.StrictMode throws warning because of `findDOMNode ...
Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of StyledComponent which is inside StrictMode. Instead, add ...
Read more >React warning: findDOMNode is deprecated in StrictMode ...
The Problem When working with React.js, you will probably come across an annoying warning: Warning: findDOMNode is deprecated in StrictMode.
Read more >Strict Mode - React
StrictMode currently helps with: Identifying components with unsafe lifecycles; Warning about legacy string ref API usage; Warning about deprecated findDOMNode ...
Read more >How do I fix warning findDOMNode is deprecated ... - YouTube
How to fix finddomnode warning with two different method :Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks all for your patience on this one, and thanks @GabrielMajeri for the pull request! The fix will be in the next release.
The PR (https://github.com/ionic-team/ionic-framework/pull/21932) has been merged 🎉