palantir / blueprint

A React-based UI toolkit for the web
https://blueprintjs.com/
Apache License 2.0
20.75k stars 2.18k forks source link

Support React Strict Mode #3361

Closed stevehollaar closed 5 years ago

stevehollaar commented 5 years ago

Environment

Feature request

Support React Strict Mode to remove unsafe lifecycles, etc. See: https://reactjs.org/docs/strict-mode.html

Examples

Currently when wrapping Blueprint components with <React.StrictMode>, several warnings are exposed as console errors:

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Blueprint3.ResizeSensor which is inside StrictMode. Instead, add a ref directly to the element you want to reference.
componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead: Blueprint3.Overlay, Blueprint3.Popover
componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead: Blueprint3.Spinner,

(There are probably others)

silverwind commented 5 years ago

It seems since React 16.9.0, componentWillReceiveProps usage now logs warnings in non-strict mode too while running tests. Please either rename to UNSAFE_componentWillReceiveProps or remove usage.

      Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

      * Move data fetching code or side effects to componentDidUpdate.
      * If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
      * Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

      Please update the following components: Blueprint3.Overlay, Blueprint3.Toaster
noambenami commented 4 years ago

I'm using react 16.13.1 and blueprint 3.26.1. I'm still seeing this error....is that expected?

Ah - I see https://github.com/palantir/blueprint/issues/3979 is still open.

muratbeser commented 4 years ago

image I'm also having issues with strict mode.

BenMcLean981 commented 4 years ago

Until there is a fix/update, what should I do?

Biaggio74 commented 3 years ago

There is an error in React strict mode React v: 17.0.1 BlueprintJS v: 3.37.0

index.js:1 Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Blueprint3.ResizeSensor which is inside StrictMode. 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 at span at Blueprint3.ResizeSensor (http://localhost:3000/static/js/0.chunk.js:12855:43)

adidahiya commented 3 years ago

See https://github.com/palantir/blueprint/issues/3979