Answers for "invariant failed you should not use link outside a router test"

0

Invariant failed: You should not use <Link> outside a <Router>

describe('Test suits for MyComponentWithLink', () => {
it('should match with snapshot', () => {
const tree = renderer
  .create(
    <BrowserRouter>
      <MyComponentWithLink/>
    </BrowserRouter>
  )
  .toJSON();
 expect(tree).toMatchSnapshot();
 });
});
Posted by: Guest on June-02-2021
0

invariant failed you should not use link outside a router test

import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import App from "./App";

it("renders without crashing", () => {
  const div = document.createElement("div");
  ReactDOM.render(
<BrowserRouter>
  <App />
</BrowserRouter>,
div
  );
  ReactDOM.unmountComponentAtNode(div);
})
Posted by: Guest on June-24-2021

Code answers related to "invariant failed you should not use link outside a router test"

Code answers related to "Javascript"

Browse Popular Code Answers by Language