-
Notifications
You must be signed in to change notification settings - Fork 270
Description
Describe the bug
In an application that uses react-dropdown-tree-select, the browser console routinely shows two error level messages related to the use of the deprecated UNSAFE_componentWillMount() and UNSAFE_componentWillReceiveProps() functions. The messages state: "UNSAFE_componentWill* in strict mode is not recommended and may indicate bugs in your code. See https://react.dev/link/unsafe-component-lifecycles for details. for details."
src/index.js implements function UNSAFE_componentWillMount
src/tree/index.js implements function UNSAFE_componentWillReceiveProps
To Reproduce
The problem should be evident in any application that uses this component.
Expected behavior
The messages suggest fixes:
For UNSAFE_componentWillMount:
- Move code with side effects to componentDidMount, and set initial state in the constructor.
For UNSAFE_componentWillReceiveProps:
- 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://react.dev/link/derived-state
Screenshots
n/a
Environment:
- Microsoft Edge 139.0.3405.86 (Official build) (64-bit)
- Windows 10 Pro Version 22H2 OS Build 19045.6216
- Node v22.14.0
- Next.js 15.2.4
- React 19.0.0
- pnpm 10.15.0
Additional context
My application, Evidence Engine, uses react-dropdown-tree-select in single-select mode.