Skip to content

Conversation

@jacobo-dominguez-wgu
Copy link
Contributor

@jacobo-dominguez-wgu jacobo-dominguez-wgu commented Oct 2, 2025

Description

This PR replaces #3808, closed due to commit pollution and rebase issues.

Removing React imports that are not required anymore on newer versions. Some of the imports were deconstructed to remove the usage of the global React object.
Some files needs the global React import to handle JSX outside functions, if removed the build-docs command fails.
Most of the modifications were performed using the react/update-react-imports codemod.

Also modified the babel config file to use the JSX Transform (introduced in React 17).

Partially closes #3796

Components included:

  • src/ActionRow
  • src/Alert
  • src/Annotation
  • src/asInput
  • src/Avatar
  • src/AvatarButton
  • src/Badge
  • src/Breadcrumb
  • src/Bubble
  • src/Button

Deploy Preview

Include a direct link to your changes in this PR's deploy preview here (e.g., a specific component page).

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Netlify deploy preview, if applicable.
  • Does your change adhere to the documented style conventions?
  • Do any prop types have missing descriptions in the Props API tables in the documentation site (check deploy preview)?
  • Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
  • Were your changes tested in the example app?
  • Is there adequate test coverage for your changes?
  • Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please request an a11y review for the PR in the #wg-paragon Open edX Slack channel.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If you'd like, share your contribution in #show-and-tell.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 2, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 2, 2025

Thanks for the pull request, @jacobo-dominguez-wgu!

This repository is currently maintained by @openedx/committers-paragon.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@netlify
Copy link

netlify bot commented Oct 2, 2025

Deploy Preview for paragon-openedx-v23 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c3c2de3
🔍 Latest deploy log https://app.netlify.com/projects/paragon-openedx-v23/deploys/69027bd9d324bb000889ec9b
😎 Deploy Preview https://deploy-preview-3840--paragon-openedx-v23.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@jacobo-dominguez-wgu jacobo-dominguez-wgu marked this pull request as draft October 2, 2025 17:22
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.37%. Comparing base (35a3a1e) to head (c3c2de3).
⚠️ Report is 3 commits behind head on release-23.x.

Additional details and impacted files
@@               Coverage Diff                @@
##           release-23.x    #3840      +/-   ##
================================================
+ Coverage         94.34%   94.37%   +0.03%     
================================================
  Files               242      242              
  Lines              4276     4282       +6     
  Branches           1017     1017              
================================================
+ Hits               4034     4041       +7     
+ Misses              234      233       -1     
  Partials              8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jacobo-dominguez-wgu jacobo-dominguez-wgu marked this pull request as ready for review October 2, 2025 19:08
@jacobo-dominguez-wgu jacobo-dominguez-wgu added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Oct 2, 2025
@jacobo-dominguez-wgu jacobo-dominguez-wgu moved this from Needs Triage to Ready for Review in Contributions Oct 2, 2025
Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks great!

I left a couple comments with questions but nothing major.

Thanks for doing this cleanup!

Comment on lines 137 to 150
return (
// eslint-disable-next-line jsx-a11y/label-has-for
<label
id={`label-${this.state.id}`}
htmlFor={this.state.id}
className={classNames({
'form-check-label': this.isGroupedInput(),
})}
>
{this.props.label}
</label>
(
<label
id={`label-${this.state.id}`}
htmlFor={this.state.id}
className={classNames({
'form-check-label': this.isGroupedInput(),
})}
>
{this.props.label}
</label>
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason the second set of ( ) is being added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was added by the linter, let me remove it.

@@ -1,8 +1,8 @@
import React from 'react';
import React, { forwardRef } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does removing React not work here? If it doesn't then could you add a comment explaining what happens if you try removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added

import type {
ElementType, ComponentType, ReactNode, ForwardedRef, AriaRole,
} from 'react';
import React, { forwardRef } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does removing React not work here? If it doesn't then could you add a comment explaining what happens if you try removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added.

"presets": [
["@babel/preset-env", { "modules": false } ],
["@babel/preset-react", { "useSpread": true } ],
["@babel/preset-react", { "useSpread": true, "runtime": "automatic" } ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these needed for this PR? If not, I think it makes sense to split this change out into a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is only needed the one for the test env.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels very odd to me that this would only be an issue when running tests and not when using Paragon installed in an MFE.

I tested this locally by pulling this branch (dccbbdf as of writing) and running npm run build to get a dist directory, then configuring module.config.js (renamed to module.config.mjs) in the authoring MFE (which uses ActionRow on the homepage) to use Paragon from that dist directory and everything seemed to still work.

In general the fact that we have a different babel config for our tests than the standard build is a bit concerning to me.

I'd like to see if anyone else has thoughts on this before moving forward with it. @diana-villalvazo-wgu, @bradenmacdonald, @PKulkoRaccoonGang, @wgu-jesse-stewart - any opinions on the best path forward here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, if we can have same configs between tests and real env will be great to avoid future discrepancies between envs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I will keep it to have same config for build and tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, if we can have same configs between tests and real env will be great to avoid future discrepancies between envs

I 100% agree.

So this leaves us with:

Option Outcome
Only change @babel/preset-react runtime for tests Builds might break in a way we don't catch because of the difference
Change @babel/preset-react runtime for everything Possibly impact consuming applications?

If this breaks tests for consuming MFEs then it should land on next as a breaking change, or we should find a way to do it as non-breaking. If we can confirm changing the @babel/preset-react runtime doesn't break anything for consuming MFEs then I think we can land it as non-breaking and add links to documentation about the implications of the change to the commit so it appears in the release notes.

Copy link
Contributor Author

@jacobo-dominguez-wgu jacobo-dominguez-wgu Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So as discussed on slack, I bumped the react peer dependency version to 16.14 since it is backported according to this docs, in that way we can keep same babel configs for test and build, so it can represent a non-breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is only needed the one for the test env.

Considering that I found issues with React imports on the documentation site (see my comment: #3840 (review)
), the test errors we see without adding "runtime": "automatic" for @babel/preset-react actually reveal a real problem that should be addressed.

In my opinion, if we can have same configs between tests and real env will be great to avoid future discrepancies between envs

We definitely need to have consistent configurations across environments. That way, we can be confident that our tests accurately ensure the code works as expected 💯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config was changed to have the same on both environments.

Copy link
Contributor

@PKulkoRaccoonGang PKulkoRaccoonGang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR! I’ve left a few minor comments. The main issue I see at the moment is the React import error, which can be observed on the Paragon documentation site.

Some pages where I found errors:

@jacobo-dominguez-wgu
Copy link
Contributor Author

Thank you for this PR! I’ve left a few minor comments. The main issue I see at the moment is the React import error, which can be observed on the Paragon documentation site.

Some pages where I found errors:

After researching I realized there was needed a special config on the gatsby-node for the documentation site in order to make the runtime automatic work, I added that and now all the components you mentioned were having issues now work ok.
Also I tested the ActionRow on the authoring mfe and looks with no problems.
I will mark the rest of prs as drafts and wait for this to be merged to integrate the the gatsby and babel settings modifications.

@PKulkoRaccoonGang
Copy link
Contributor

It appears that removing React imports from some components has caused issues in the Playground.

The problem is triggered by the Button component, even though it (like the ActionRow component) no longer includes a direct React import.

image

@jacobo-dominguez-wgu
Copy link
Contributor Author

It appears that removing React imports from some components has caused issues in the Playground.

The problem is triggered by the Button component, even though it (like the ActionRow component) no longer includes a direct React import.

image

@PKulkoRaccoonGang I have pushed a new commit to solve this problem.

"presets": [
["@babel/preset-env", {}],
["@babel/preset-react", { "useSpread": true } ],
["@babel/preset-react", { "useSpread": true, "runtime": "automatic" } ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep same babel configs for test and build, so it can represent a non-breaking change.

@jacobo-dominguez-wgu if we’ve decided that the @babel/preset-react configuration should be used across all environments, and we’ve already added it to the presets on line 4 of this file, do we still need to duplicate @babel/preset-react under the test environment?

Since the presets section on line 4 defines the base configuration - for example, @babel/preset-env is defined there and then overridden with {} (CommonJS) for the test environment - it seems we can safely remove @babel/preset-react from env.test.presets and keep it only in the global configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I removed it from the test env config. The tests remain working.

@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Oct 29, 2025
@brian-smith-tcril
Copy link
Contributor

@jacobo-dominguez-wgu I'm hoping to get some movement on this PR and the 10 other react import cleanup PRs. I think all the review comments on here have been addressed but I'd need to double check.

@wgu-jesse-stewart do you have any bandwidth to look at this (and hopefully also the other 10)? For this one it'd just be great to get a fresh set of eyes on it to make sure the concerns raised in previous reviews are addressed and nothing else sticks out as problematic. Seeing a 👍 from you before I dive into another review on this would be wonderful!

@jacobo-dominguez-wgu
Copy link
Contributor Author

@jacobo-dominguez-wgu I'm hoping to get some movement on this PR and the 10 other react import cleanup PRs. I think all the review comments on here have been addressed but I'd need to double check.

@wgu-jesse-stewart do you have any bandwidth to look at this (and hopefully also the other 10)? For this one it'd just be great to get a fresh set of eyes on it to make sure the concerns raised in previous reviews are addressed and nothing else sticks out as problematic. Seeing a 👍 from you before I dive into another review on this would be wonderful!

Thanks @brian-smith-tcril I am expecting to get this approved to apply the same changes to the other 10PRs.
Also if you @wgu-jesse-stewart and @diana-villalvazo-wgu guys can do a review would be awesome, very appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

Remove unnecessary React imports

5 participants