M
M
Maxim Kaygorodov2019-03-01 19:33:02
React
Maxim Kaygorodov, 2019-03-01 19:33:02

How to send props through react-route?

There is some PublishedArticle.js from which you need to send props, which will be const article, to the PublishedArticlePage component, which is called via Route

function PublisedArticle(props) {
    const article = props.article
    return (
        <Router history={history}>
            <Link to='/publishedArticlePage'>
               <SomeLinkContent/>
                </Link>      
                <Route path='/publishedArticlePage' component={PublishedArticlePage}/>
        </Router>
    )}

export default PublisedArticle

How to do it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2019-03-01
@makosek

somehow it should work

<Route 
  path='/publishedArticlePage' 
  render={ (props) => <PublishedArticlePage {...props} article={article} } 
/>

https://tylermcginnis.com/react-router-pass-props-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question