Coder Social home page Coder Social logo

Comments (3)

Kfelts avatar Kfelts commented on June 1, 2024 1

Which version of React and React Router are you using? React Router v6 made a lot of changes.

Warning: React does not recognize the computedMatch prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase computedmatch instead. If you accidentally passed it from a parent component, remove it from the DOM element. ReferenceError: Can't find variable: process ```

TypeScript error in /app/src/index.tsx(8,4): 'Router' cannot be used as a JSX component. Its instance type 'BrowserRouter' is not a valid JSX element. The types returned by 'render()' are incompatible between these types. Type 'React.ReactNode' is not assignable to type 'import("/node_modules/@types/react-transition group/node_modules/@types/react/index").ReactNode'. TS2786

     6 | 
     7 | ReactDOM.render(
  >  8 |   <Router>
       |    ^
     9 |     <App />
    10 |   </Router>,
    11 |   document.getElementById('root')

ReactDOM.render has been changed to createRoot.

 1 | Import { createRoot} from 'react-dom/client'

6  | const container = document.getElementById('root');
7  | const root = createRoot(container!);
8  | root.render(
9  |    <Router >
10 |        <App />
11 |   <Router />
12 | );
'Switch' cannot be used as a JSX component.
  Its instance type 'Switch' is not a valid JSX element.```

In v6 'Switch' was removed entirely. 'Switch' is now 'Routes'

The types returned by 'render()' are incompatible between these types.
Type 'React.ReactNode' is not assignable to type 'import("/node_modules/@types/react-transition-group/node_modules/@types/react/index").ReactNode'. TS2786

There have also been changes made in the way that routes are rendered. This is what it looked like prior:

    <header className={classes.header}>
      <Route path="/login" component={Login} />
        <Login />
      <Route path="/signup" component={SignUp} />
      <Route
        path="/logout"
        render={() => {
          logout();
          history.push('/');
          return null;
        }}
      />
      <PrivateRoute path="/protected" component={Protected} />
      <Route exact path="/" component={Home} />
    </header>
  </div>
</Routes>

This requires some refactoring, so I'd recommend taking a look at what upgrades are needed for React 18 and react hooks

'Redirect' cannot be used as a JSX component. 

In v6 'Redirect' has been changed to 'Navigate'. Change 'useHistory' to 'useNavigate' and then 'Redirect' to 'Navigate' in the jsx component.

from fastapi-react.

chhopsky avatar chhopsky commented on June 1, 2024 1

They're using the version that's in the clean install, as described in the readme.md

I see the same behavior following the instructions provided, and given I was installing this to start playing with and learning react, makes the whole thing pretty useless.

from fastapi-react.

kevingigiano avatar kevingigiano commented on June 1, 2024

Confirmed this is still a problem.

I was hoping to use this as a basis for a pet project/learning.

Unfortunately, standing up from scratch using README results in a broken state as mentioned by @Kfelts and @chhopsky

from fastapi-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.