Skip to content

Refactor Editor/index.jsx to functional React component #3309

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

Conversation

Vishawdeep-Singh
Copy link
Contributor

@Vishawdeep-Singh Vishawdeep-Singh commented Dec 25, 2024

Refactored : Todo - Convert the Editor/index.jsx to React functional component

Changes: Added a new file called "oldClassComponent.jsx" so original class component remains there. Replaced index.jsx with new functional component code.

Video- https://drive.google.com/file/d/1iFMe2Cc_KBI9-QoaQGz8gJU7N473UGZa/view?usp=sharing

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

@Vishawdeep-Singh
Copy link
Contributor Author

@raclim Can you review this . Please

Copy link
Collaborator

@raclim raclim left a comment

Choose a reason for hiding this comment

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

Thanks so much for giving this a shot!

Unfortunately I don't think we'll be able to accept this pull request as we're currently reworking this component for a project we started earlier last year, which was upgrading the CodeMirror version.

However, I think this is a great start and gave a few notes on a few changes I might make on this pull request! I think one additional note I'd make is that the component does not appear to be fully functional yet, and crashes when attempting to save a sketch. We strongly encourage doing both unit and manual testing on your code before submitting a pull request!

I'm sorry that we couldn't get this one in, but please feel free to check out our other issues.

@@ -3,6 +3,7 @@ const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally, we would like to isolate changes in each pull request to relate as much as possible to the issue. It seems like the changes in this file aren't related to the Editor component refactor, so I might remove these!

@@ -113,6 +113,7 @@
"babel-core": "^7.0.0-bridge.0",
"babel-loader": "^8.2.5",
"babel-plugin-transform-react-remove-prop-types": "^0.2.12",
"browserify-zlib": "^0.2.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here as well with removing changes that may not be related to the issue!

@@ -0,0 +1,716 @@
// TODO: convert to functional component
Copy link
Collaborator

Choose a reason for hiding this comment

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

In order to help keep the repository directory easy to navigate, ideally we would not create a new file holding the component, and would just make our changes directly to the index.jsx file.

Because of the way Git works, the history would be preserved in case we would ever want to look back at the old component!

}
}, [props.file.id, props.file.name, props.unsavedChanges]);

// useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

To maintain readability, we'd ideally only want to include comments that provide supportive information about the code!

@raclim raclim closed this Feb 7, 2025
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.

2 participants