apm-agent-rum-js icon indicating copy to clipboard operation
apm-agent-rum-js copied to clipboard

support react-router-dom v17

Open vrecan opened this issue 2 years ago • 1 comments

When using v17 of react-router-dom I get the following error:

apm Uncaught Error: "[ApmRoute2]" is not a <Route> component. 
All component children of <Routes> must be a <Route> or <React.Fragment>

Here is the code example, this works when I switch out the apmRoute for a normal Route

  return (
    <>
      {!isIdle && <Heartbeat setIsLoggedIn={setIsLoggedIn} />}
      <Router>
        <Routes>
          <ApmRoute path="/login" element={<Login />} />
          <ApmRoute path="/" element={<Desktop />}>
            <ApmRoute index element={<AgentDashboard />} />
            <ApmRoute
              path="/conversations/:conversationId"
              element={<CurrentConversation />}
            />
            <ApmRoute path="/conversations/new" element={<NewConversation />} />
          </ApmRoute>
        </Routes>
      </Router>
    </>
  );
};

Here are my imports:

import { useState } from 'react';
import { QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { ApmRoute } from '@elastic/apm-rum-react';

import { Login } from './components';
import { AgentDashboard } from './domains/AgentDashboard';
import { CurrentConversation } from './domains/CurrentConversation';
import { ModalProvider } from './domains/Modal';
import { NewConversation } from './domains/NewConversation';
import { Desktop } from './domains/Desktop';
import { queryClient, state, hooks } from './utils';

From what I can tell apmRoute isn't extending Route.

vrecan avatar Mar 03 '22 00:03 vrecan

Hi @vrecan ,

Thanks for reaching out. At this moment the agent does not have out-of-the-box support for react-router-dom v6. It supports v4 and v5.

In this issue we offer possible tradeoffs that might be helpful for you.

We still don't have plans to start the development to add the v6 support.

Thanks, Alberto

devcorpio avatar Mar 03 '22 09:03 devcorpio

Any updates on plan to make devs for react-router v6 support ?

jbournonville avatar Nov 25 '22 10:11 jbournonville

Any updates on plan for react-router-dom v6 support?

puunukk avatar Feb 07 '23 13:02 puunukk

Hello to everyone following this issue. Apologies for the slow replies. I can confirm that we intend to deliver this support with an update coming to our RUM-JS agent this summer.

drewpost avatar May 12 '23 11:05 drewpost

Hey @drewpost , Do you have an update on your 'RUM-JS agent release' delivery planning regarding v6 support?

LeaTaka avatar Jul 05 '23 08:07 LeaTaka

Hi @LeaTaka,

yes, as Drew previously commented we intend to deliver this support with an update coming to our RUM-JS agent this summer. The team is already focused on this, we will update this ticket in the upcoming weeks once the development is finished.

Thanks again for your patience.

Alberto

devcorpio avatar Jul 05 '23 12:07 devcorpio

coming up to a month later since last response, would love to be able to use apm-agent-rum-js with the latest major version of react-router-dom

pkrauss-prot avatar Aug 03 '23 18:08 pkrauss-prot

Thanks for your patience, we are actively working on this and hope to share an further update in the coming weeks

paulb-elastic avatar Aug 04 '23 09:08 paulb-elastic

Hi everyone,

there is a new release for the @elastic/apm-rum-react, the version is 2.0.0.

Shortly we will update the react docs with more info, but you can see the preview here:

https://github.com/elastic/apm-agent-rum-js/pull/1411

Now, there will be a new component name ApmRoutes:

e.g.

      <BrowserRouter>
        <ApmRoutes>
          <Route path="/" element={<HomeComponent />} />
          <Route path="/about" element={<AboutComponent />} />
        </ApmRoutes>
      </BrowserRouter>

All routes within ApmRoutes will be instrumented.

Thanks again for your patience

Alberto

devcorpio avatar Aug 08 '23 19:08 devcorpio