question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: deprecated findDOMNode usage with React.StrictMode

See original GitHub issue

Bug 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 inside React.StrictMode. Does that mean that you guys don’t support StrictMode right now, what is the plan for Ion components to work with StrictMode?

Expected behavior:

Avoid using findDOMNode to refer to an element, hence not getting this error on React Strict mode

Steps to reproduce:

  1. Create a React app with create-react-app
  2. Make sure <App /> component is wrapped inside React.StrictMode
  3. 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>
);
  1. Run yarn start
  2. Check browser console

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
elylucascommented, Nov 25, 2020

Thanks all for your patience on this one, and thanks @GabrielMajeri for the pull request! The fix will be in the next release.

5reactions
GabrielMajericommented, Nov 25, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found