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

Passing props to route

Open satyadeeproat opened this issue 9 years ago • 3 comments

I want to pass props to routes. I am doing it this way but getting error. Failed prop type: Invalid prop routes supplied to Router in Router Anyone knows what I am doing wrong

const routeConfig = (type) => {
  return (      
  <Route>
  <Route path='/' component={Template}>
    <Route path='/pageform(/:id)' component={PageForm} />
  </Route>
  
  <Route path='/:pageSlug' component={Page} type=type/>
  </Route>
);
}
class App extends React.Component {
  render() {
    return (
      <MuiThemeProvider muiTheme={getMuiTheme()}>
        <Provider store={store}>
          <Router history={browserHistory} routes={routeConfig type='abc'} />
        </Provider>
      </MuiThemeProvider>
    );
  };
};

satyadeeproat avatar Dec 27 '16 08:12 satyadeeproat

Shouldn't it be <Route path='/pageform/:id' component={PageForm} />

priyadhoundiyal avatar Dec 27 '16 10:12 priyadhoundiyal

@priyadhoundiyal : The params is optional that's why it has been written as <Route path='/pageform(/:id)' component={PageForm} /> rather than <Route path='/pageform/:id' component={PageForm} />

The problem is with passing the props argument type which i don't know is write way to do or not

satyadeeproat avatar Dec 27 '16 10:12 satyadeeproat

This is a bug tracker, not a support system. For usage questions, please use Stack Overflow or Reactiflux. Thanks!

timdorr avatar Dec 28 '16 23:12 timdorr