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

'HashRouter' cannot be used as a JSX component #7781

Closed
aslanovsergey opened this issue Mar 3, 2021 · 2 comments
Closed

'HashRouter' cannot be used as a JSX component #7781

aslanovsergey opened this issue Mar 3, 2021 · 2 comments

Comments

@aslanovsergey
Copy link

I added react-router 5 into my project where i use typescript (v 3.9) but when I try to use react router i get an error:
'HashRouter' cannot be used as a JSX component. Its instance type 'HashRouter' is not a valid JSX element. The types returned by 'render()' are incompatible between these types. Type 'ReactNode' is not assignable to type 'false | Element'. Type 'string' is not assignable to type 'false | Element'.

Here is how my render method look like

  public render(): React.ReactElement<IVacationRequestsProps> {
    return (
      <div className={styles.vacationRequests}>
        <HashRouter>
          <Route path="/" exact component={VacationsRequestList}></Route>
        </HashRouter>
      </div>
    );
  }
@timdorr
Copy link
Member

timdorr commented Mar 3, 2021

Something else is going on here, because there's no reason that bit of code should be invalid. Check how you're importing the component or your build system. This isn't an issue with React Router.

@timdorr timdorr closed this as completed Mar 3, 2021
@simonv3
Copy link

simonv3 commented Jul 26, 2022

This might be related to #8794

@remix-run remix-run deleted a comment from saeid-shoja Nov 27, 2022
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

No branches or pull requests

3 participants