preact-router icon indicating copy to clipboard operation
preact-router copied to clipboard

Props of Router component children are being erased

Open malchata opened this issue 8 years ago • 1 comments
trafficstars

Right now I'm running into a strange situation where the Router component will erase props on child components. For example, I have a Slides component that is the only child of Router:

render(){
  return (
    <Router>
      <Slides path="/:slide?" slide="1" default />
    </Router>
  );
}

Inside of the slide component, this.props.slide is always an empty string, no matter what I set it to. If I remove the Router component around the Slides component, this.props.slide populates properly.

Some pertinent version info: preact 8.1.0 preact-router 2.5.2 webpack 2.4.1

Currently using the babel-plugin-transform-react-jsx plugin to parse JSX. Are there any reasons why this would occur? I feel like it's a bug.

Thanks!

malchata avatar May 02 '17 02:05 malchata

Ah - that's interesting. Router is definitely always overriding that property value. Interestingly, it only happens if you include ? in the route.

developit avatar May 07 '17 15:05 developit