Skip to content

Chore/react deprecation warnings #2022

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

Closed
wants to merge 13 commits into from

Conversation

catarak
Copy link
Member

@catarak catarak commented Apr 28, 2022

Fixes #2021

Changes:
Removes many of the React deprecation warnings. The rest of the warnings can be removed when upgrading to React 18.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@release-com
Copy link

release-com bot commented Apr 28, 2022

Release Environments

This pull request environment is provided by Release, learn more!
To see the status of the environment click on Environment Status below.

🔧Environment Status : https://app.releasehub.com/public/Processing%20Foundation/env-c4a0807a28

@raclim raclim added the Create Release Environment For use with ReleaseHub ephemeral environments label Apr 14, 2023
@raclim raclim closed this Jul 11, 2023
@raclim raclim deleted the chore/react-deprecation-warnings branch July 11, 2023 14:44
@raclim raclim restored the chore/react-deprecation-warnings branch July 11, 2023 16:17
@raclim raclim reopened this Jul 11, 2023
@raclim
Copy link
Collaborator

raclim commented Jul 18, 2023

I upgraded react-helmet to its latest version, v6.1.0, and react-tabs to 3.2.3, which is the latest one compatible with our current version of React. I think #2218 can address the remaining warnings for now.

@raclim raclim requested a review from lindapaiste July 18, 2023 21:51
Copy link
Collaborator

@lindapaiste lindapaiste left a comment

Choose a reason for hiding this comment

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

These are mostly positive changes, though it will create conflicts with some of the work that @dewanshDT has been doing and with some of my existing PRs.

I just looked at the code and I haven't loaded it up to make sure that the tabs still work as expected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have an open PR that converts App to a function component but this looks right.

type: ActionTypes.SET_PROJECTS,
projects: response.data
return (dispatch) =>
new Promise((resolve) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this accomplishes anything? When we return apiClient.get().then().catch() that is already returning a Promise.

IMO we should stay away from explicit new Promise((resolve) => syntax unless it's for the purpose of converting a callback-based result to a Promise. ie. someFunction(arg, (err, res) => { if (err) { reject(err); } else { resolve(res); }}).

You could keep it as-is. You could also convert it to async/await (return async (dispatch) => {) as async functions always return a Promise.

componentDidUpdate(prevProps) {
// if the url has changed to open a new sketch
if (this.props.params.project_id && !prevProps.params.project_id) {
if (this.props.params.project_id !== this.props.project.id) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the same condition that was there before...but does it make sense? It's saying we should load the project if we have an id AND we did not have an id previously AND we have not already loaded the project for that id. I don't think we want the && !prevProps.params.project_id part. What if this.props.params.project_id changes from one valid id to another valid id?

@@ -298,7 +286,9 @@ class IDEView extends React.Component {
<main className="editor-preview-container">
<SplitPane
split="vertical"
size={this.state.sidebarSize}
size={
this.props.ide.sidebarIsExpanded ? this.state.sidebarSize : 20
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was actually something that I discussed with @dewanshDT in his rewrite of this component (he has it converted to a function component). We came to the same conclusion you did here -- that it's better for the state to just store the expanded size.

} else {
url = '/projects';
}
return apiClient
Copy link
Collaborator

@lindapaiste lindapaiste Jul 19, 2023

Choose a reason for hiding this comment

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

There's an eslint rule against using return within new Promise(). But maybe that one only showed up in the branch where I updated eslint. https://eslint.org/docs/latest/rules/no-promise-executor-return

With the previous structure, the return statement on this line causes it to return a Promise. With the current/proposed structure, the return doesn't do anything and should be deleted.

@lindapaiste
Copy link
Collaborator

I upgraded react-helmet to its latest version, v6.1.0

Did that actually fix the warnings? My understanding is that react-helmet is dead and we need to switch to react-helmet-async.

@raclim
Copy link
Collaborator

raclim commented Sep 11, 2023

Some of these changes have fallen out of date, so I'm going to close this for now!

@raclim raclim closed this Sep 11, 2023
@raclim raclim deleted the chore/react-deprecation-warnings branch October 11, 2023 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Create Release Environment For use with ReleaseHub ephemeral environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove React warnings
3 participants