Skip to content

Conversation

@ben-smartbear
Copy link
Contributor

When iterating over an immutable map in React 16, the keys are rendered to the screen alongside the content.

Description

This uses the established entrySeq pattern to iterate without rendering keys.

Motivation and Context

When using Swagger UI in an React 16 environment, and using requestSnippetsEnabled: true, indexes are rendered when they should not appear. This resolves the issue.

How Has This Been Tested?

Added the change to local Swagger UI and rendered in React 15 correctly.
Added the changes to Swagger UI and imported new changed library to React 16 environment and observed correct rendering.

Screenshots (if appropriate):

image

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@mathis-m
Copy link
Contributor

mathis-m commented Apr 6, 2021

@ben-smartbear do you know why this happened?

@ben-smartbear
Copy link
Contributor Author

@ben-smartbear do you know why this happened?

The react 16 fiber renderer dumps out the keys of immutable objects when iterating over them: immutable-js/immutable-js#667

This isn't the first time this issue has been seen in swagger ui and until the library updates React, it likely won't be the last :)

@tim-lai tim-lai merged commit 7fc2780 into swagger-api:master Apr 14, 2021
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.

3 participants