swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.56k stars 8.96k forks source link

swagger-ui-react - update old lifecycle methods #5729

Open nirsky opened 4 years ago

nirsky commented 4 years ago

Q&A (please complete the following information)

Usage Example:

import SwaggerUI from "swagger-ui-react";

<SwaggerUI spec={doc.openApiSpec!} docExpansion={"none"} key={doc._id!} />

Describe the bug you're encountering

Getting the following warnings in the browser console:

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles 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: Connect(r)

Warning: componentWillUpdate has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* Rename componentWillUpdate to UNSAFE_componentWillUpdate 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: Connect(r)

Additional context or thoughts

Please update lifecycle methods to use UNSAFE keyword.

kyeotic commented 4 years ago

The version of react they depend on was published 2 years ago, long before those methods became deprecated

silverwind commented 4 years ago

Seeing a slightly different warning while testing components that import swagger-ui-react:

componentWillReceiveProps:
Please update the following components: Connect(r), Provider
componentWillUpdate:
Please update the following components: Connect(r)
fcoralsasso commented 3 years ago

Any update on this?

wshart commented 3 years ago

Bump

DjVreditel commented 3 years ago

Bump AGAIN

masoudsoleymani commented 2 years ago

Facing the same issue:

Screen Shot 2022-07-13 at 14 10 07

Any solution?

syshriki9 commented 2 years ago

I'm seeing this too. Bump!

bmpf commented 2 years ago

Same problem here.

Jul13nT commented 1 year ago

Is the React component still maintained ? No update on this issue since 3 years...

char0n commented 1 year ago

I've counted that the codebase contains:

In order to make the situation better, we have to replace each of this methods either with hooks or other SAFE lifecycle methods.

We can start issuing PRs and eliminate one method at a time. I'll be able to provide PR and merge very quickly if you give me a mention here.

Any first volunteers?