Search code examples
javascriptreactjsjsxstyled-componentsreact-static

How do I use NavLink in React Static 7?


I am updating a React Static website that was created with version 5.9.12 to version 7.2.2.

It seems that NavLink was removed from React Static. With the following code I get an error: Cannot create styled-component for component: undefined.

import React from "react";
import { NavLink } from "react-static";
import styled from "styled-components";

const NavLinkStyled = styled(NavLink)`
  color: #444;
`;

export default ({ link }) => (
  <NavLinkStyled to={link}>
  </NavLinkStyled>
);

I couldn't find in the React Static documentation or on the Internet if it was really removed.

Do I need to replace NavLink with something else?


Solution

  • You can use a router, like @reach/router and replace the NavLink by Link, this is the only way I could do it.