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

Getting UNSAFE_componentWillReceiveProps error when using Next.js 15 / React 19 #10212

Open
petergoldstein opened this issue Nov 11, 2024 · 10 comments · May be fixed by #10373
Open

Getting UNSAFE_componentWillReceiveProps error when using Next.js 15 / React 19 #10212

petergoldstein opened this issue Nov 11, 2024 · 10 comments · May be fixed by #10373
Labels
cat: rendering javascript Pull requests that update Javascript code P2 pull-request-welcome If a PR were to be made, we would help get it merged type: enhancement

Comments

@petergoldstein
Copy link

Q&A (please complete the following information)

  • OS: macOS
  • Browser: Chrome 130.0.6723.117
  • Method of installation: pnpm
  • Swagger-UI version: 5.18.2
  • Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.1.0

Content & configuration

I'm using a vanilla Swagger Page inside a Next.js 15 / React 19 application:

"use client";

import { useEffect, useState } from "react";
import SwaggerUI from "swagger-ui-react";
import "swagger-ui-react/swagger-ui.css";

function SwaggerPage() {
  const [spec, setSpec] = useState<any>(null);

  useEffect(() => {
    fetch("/api/swagger")
      .then((response) => response.json())
      .then((data) => setSpec(data));
  }, []);

  if (!spec) {
    return <div>Loading...</div>;
  }

  return <SwaggerUI spec={spec} />;
}

export default SwaggerPage;

Describe the bug you're encountering

I'm seeing the following error starting in Swagger-UI 5.18.0 and continuing through 5.18.2 on my Swagger page:

Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://react.dev/link/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://react.dev/link/derived-state

Please update the following components: OperationContainer

To reproduce...

Steps to reproduce the behavior:

  1. Go to the Swagger UI page
  2. Page throws an error

Expected behavior

No error

Screenshots

Screenshot 2024-11-11 at 10 36 22 AM

@tazo90
Copy link

tazo90 commented Nov 15, 2024

Next.js 15 uses Strict Mode by default, which is why we encountered this issue.
swagger-ui-react still uses the deprecated UNSAFE_componentWillReceiveProps in several places.

Is there a possibility to refactor them?

@harmonicaCz
Copy link

Same problem as well

@javierlinked
Copy link

Bump here.

@sbbu
Copy link

sbbu commented Feb 3, 2025

bump!

@GreatPotato
Copy link

GreatPotato commented Feb 12, 2025

Double bump 😎

@unclebay143
Copy link

More bump 🫡

@70nyIT
Copy link

70nyIT commented Feb 19, 2025

bump too!

@ponelat ponelat added P2 type: enhancement cat: rendering javascript Pull requests that update Javascript code pull-request-welcome If a PR were to be made, we would help get it merged labels Feb 21, 2025
@thorsten
Copy link

thorsten commented Mar 9, 2025

Any news on this?

@jryanthe4th jryanthe4th linked a pull request Mar 17, 2025 that will close this issue
17 tasks
@Stanley-Jovel
Copy link

Bump x 3

@jbh-eva
Copy link

jbh-eva commented Mar 26, 2025

Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat: rendering javascript Pull requests that update Javascript code P2 pull-request-welcome If a PR were to be made, we would help get it merged type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.