Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Weird problem when using StyleRoot component with react-router #1000

Closed
@WJWang

Description

@WJWang

I use radium with react-router I found that when I wrapped the <BrowserRouter> component inside the <StyleRoot> everything works fine. The browser, link, redirection behavior works well.

The example code show as below:

import React from 'react';
import { StyleRoot } from 'radium';
import { BrowserRouter, Route, Link } from "react-router-dom";

const Home = () => (
  <div>
    <h2>Home</h2>
  </div>
);

const About = () => (
  <div>
    <h2>About</h2>
  </div>
);

export default (
  <StyleRoot>
    <BrowserRouter>
      <div>
        <ul>
          <li>
            <Link to="/">Home</Link>
          </li>
          <li>
            <Link to="/about">About</Link>
          </li>
        </ul>
        <hr />
        <Route exact path="/" component={Home} />
        <Route path="/about" component={About} />
      </div>
    </BrowserRouter>
  </StyleRoot>
);

However, when I put the <StyleRoot> in the <BrowserRouter>, it will cause the browser action failed.
The redirection and the links are all out of work but no any errors comes out.

...
...
export default (
  <BrowserRouter>
    <StyleRoot>
      <div>
        <ul>
          <li>
            <Link to="/">Home</Link>
          </li>
          <li>
            <Link to="/about">About</Link>
          </li>
        </ul>
        <hr />
        <Route exact path="/" component={Home} />
        <Route path="/about" component={About} />
      </div>
    </StyleRoot>
  </BrowserRouter>
);

The package version info:

react:  ^16.4.2
react-router: ^4.3.1
react-router-dom: ^4.3.1
radium: ^0.24.1

I am not quite sure it a bug or using <StyleRoot> in a wrong way.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions