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

React: Remove redundant default imports of React from code examples #28602

Merged

Conversation

Victor-M-Giraldo
Copy link
Contributor

Because

Some of the lessons in the React section still had the default React import. This is no longer required.

This PR

  • Removed default imports from Class-based components
  • Removed default imports from Refs and memoization
  • Removed default imports from How to deal with side effects
  • Removed default imports from Type checking with proptypes

Issue

Closes #28592

Additional Information

None

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

@github-actions github-actions bot added the Content: React Involves the React course label Aug 9, 2024
Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

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

Thanks for removing these. I think you forgot to also remove the redundant imports from Introduction to React Testing, the lesson the original issue was about 😛

@Victor-M-Giraldo
Copy link
Contributor Author

Oops haha. Got it.

Irrelevant to this issue, but I noticed this in the React Router lesson.

import { createBrowserRouter, RouterProvider } from "react-router-dom";
import React from "react";
import ReactDOM from "react-dom/client";
import routes from "./routes";

const router = createBrowserRouter(routes);

ReactDOM.createRoot(document.getElementById("root")).render(
  <React.StrictMode>
    <RouterProvider router={router} />
  </React.StrictMode>
);

When you make a react app with Vite it doesn't import React, it just does the destructuring directly import { StrictMode } from 'react';. Not sure if that's a huge deal though

Copy link
Contributor

@MaoShizhong MaoShizhong left a comment

Choose a reason for hiding this comment

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

🚀

I'm not particularly fussed about the strict mode import. People are aware about named and default imports already. The React default imports in this PR were actually redundant since they weren't being used at all.

@MaoShizhong MaoShizhong merged commit 6ecd277 into TheOdinProject:main Aug 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content: React Involves the React course
Projects
None yet
Development

Successfully merging this pull request may close these issues.

React: Some React examples import React without needing to.
2 participants