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

fix: React 17 findDOMNode is deprecated #27755

Merged
merged 6 commits into from
Nov 16, 2020

Conversation

hosseinmd
Copy link
Contributor

@hosseinmd hosseinmd commented Nov 13, 2020

[中文版模板 / Chinese template]
findDOMNode is Deprecated we should use ref.

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

close #22493
ref #26136

💡 Background and solution

Use ref instead of findDOMNode

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Nov 13, 2020

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 13, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 24c5a31:

Sandbox Source
antd reproduction template Configuration

@codecov
Copy link

codecov bot commented Nov 13, 2020

Codecov Report

Merging #27755 (24c5a31) into master (7b9a794) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master    #27755   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          390       390           
  Lines         7387      7393    +6     
  Branches      2042      2044    +2     
=========================================
+ Hits          7387      7393    +6     
Impacted Files Coverage Δ
components/_util/wave.tsx 100.00% <100.00%> (ø)
components/anchor/Anchor.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b9a794...24c5a31. Read the comment docs.

@trane294
Copy link

Please merge

@goulkreek
Copy link

Please Merge. "findDOMNode" warning is really annoying.

@zombieJ
Copy link
Member

zombieJ commented Nov 16, 2020

@hosseinmd
Copy link
Contributor Author

components/_util/wave.tsx Outdated Show resolved Hide resolved
@hosseinmd
Copy link
Contributor Author

used supportRef

@hosseinmd
Copy link
Contributor Author

I removed setAndForwardRef and used composeRef instead

@zombieJ zombieJ merged commit 4b1000f into ant-design:master Nov 16, 2020
@goulkreek
Copy link

Fixed for me with release 4.8.4 !
Thx a lot !

@ogrotten
Copy link

ogrotten commented Dec 21, 2020

I am receiving this error on 4.9.4 using Upload component. It is the only component in use as I'm just getting started on this project.

My code:

import React, { useState } from 'react';

import { Upload, Button, message } from 'antd';
import { UploadOutlined } from '@ant-design/icons';

import "antd/dist/antd.css";
import './App.css';

function App() {
	const [fileList, updateFileList] = useState([]);
	const props = {
		fileList,
		beforeUpload: file => {
			if (file.type !== 'application/json') {
				message.error(`${file.name} is not a json file`);
			}
			return file.type === 'application/json';
		},
		onChange: info => {
			console.log(info.fileList);
			// file.status is empty when beforeUpload return false
			updateFileList(info.fileList.filter(file => !!file.status));
		},
	};
	return (
		<div className="App">
			<Upload {...props}>
				<Button icon={<UploadOutlined />}>Upload json only</Button>
			</Upload>
		</div>
	);
}

export default App;

with a very few changes, it is exactly the example from the docs: https://ant.design/components/upload/#components-upload-demo-upload-png-only

The above code results in

Warning: findDOMNode is deprecated in StrictMode.

in the browser console with additional spam.

@casulit
Copy link

casulit commented Jan 5, 2021

Still receiving this error @4.10.0

@arocki7
Copy link

arocki7 commented Jan 31, 2021

I still have issues with 4.10.2.

@Ildorado
Copy link

Ildorado commented Feb 2, 2021

Still have the same issue with 4.11.2

@SaadEla
Copy link

SaadEla commented Feb 5, 2021

same issue on :
antd: 4.12
react: 17.0

@yoyo837
Copy link
Contributor

yoyo837 commented Feb 5, 2021

trace in #26136

@seeintea
Copy link

Still have the same issue with 4.12.3 and library version 17.0.1 when i used Menu component

@sberequek
Copy link

Hi, the problem is still present with antd 4.15.0 and react 17.0.2 when I use the Menu component.

@snxtecnologiabkp
Copy link

Hi, any updates?

@codetestmg
Copy link

any updates ?
Thanks

@jmaric
Copy link

jmaric commented Apr 6, 2022

I get same error on Menu component, any update?

@bamtheboozle
Copy link

still happens when using the Menu component with 5.3.0

@qinshuze
Copy link

2024年了当前是5.16.5版本使用Button组件依旧会出现警告:react-dom.development.js:86 Warning: findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node

@thomastvedt
Copy link

I get this on antd version 5.20.5, looks like it's coming from Tooltip / Popover component.

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

Successfully merging this pull request may close these issues.

Using <Button> results in "findDOMNode is deprecated in StrictMode" warning