Typeerror: Meta. relativePath. startsWith Is Not a Function

I'm new to react and this is just a trial for me and I got this error, Can someone help me out?? I've already tried changed route and then I got this error.

1

2 Answers

I just solved this same problem. The answer was here.

This is what I had that was causing the error.

    <Routes>
      <Route exact path={["/", "/user"]} element={Home} />
      <Route exact path="/add" element={AddUser} />
    </Routes>

And this is the fix that worked

    <Routes>
      <Route exact path="/" element={<Home />} />
      <Route exact path="/add" element={<AddUser />} />
    </Routes>
1

This error just showed up to me and it seems there are no real solutions for this problem since I made the research with no results.

I used to have my code like this, like having several routes in an array inside the path prop.

<Route exact path={['search', '/images', '/news', '/videos']} element={<Results />} />

Once I was aware there were no solutions on internet I just split every route in a single line each.

    <Route exact path='/search' element={<Results />} />
    <Route exact path='/images' element={<Results />} />
    <Route exact path='/news' element={<Results />} />
    <Route exact path='/videos' element={<Results />} />

This might not be a good solution for this but it's an option if you want to keep with your work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest