T
T
tripleserpantine2020-07-26 00:31:25
React
tripleserpantine, 2020-07-26 00:31:25

Why props.match == undefined?

<Switch>
        <Route path='/dialogue/:id' render={() => <DialogList />}/>
 </Switch>

Why is props.match being passed as undefined in the first route?
<Route path="/dialogue/:id" render={() => {console.log(props.match)}}/>

And when I call like this props.match.params is empty, and why are the transmitted props different at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
i1yas, 2020-07-26
@tripleserpantine

You yourself skip props

<Route path='/dialogue/:id' render={() => <DialogList />}/>

DialogList does not receive any props, you wrapped it in a component that ignores them, then do this:
<Route path='/dialogue/:id' render={(props) => <DialogList {...props}/>}/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question