Home > Mobile >  My App Component will not render with React
My App Component will not render with React

Time:05-09

I am doing React project with typescript form scratch, and for some reason, I can't get the App component to render. I know the file path is correct. The Error says: Module not found: Error: Can't resolve './App' in '/Users/michaelhorvilleur/Desktop/Codecademy/react-porfolio/src'

import React from "react";
import ReactDOM from "react-dom";
import App from "./App";

ReactDOM.render(<App />, document.getElementById("#root"));
import React, { useState } from "react";

const App = () => {
   return (
    <div>
      <h1>App</h1>
    </div>
  );
};

export default App;

CodePudding user response:

Hope this helps ;)

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

import App from "./App.tsx";

const rootElement = document.getElementById("root");
const root = createRoot(rootElement);

root.render(
  <StrictMode>
    <App />
  </StrictMode>
);

CodePudding user response:

Make sure the App.js file is positioned in src folder

  • Related