slimboy
slimboy

Reputation: 1653

getting empty value from this.props.match.params while it is showing in the react dev tools

Hi I am trying to access my params from my react router but it always shows me an empty object.

this is my code:

    <Switch>
    <Route exact path='/' render={(props) => (<PhotoWall {...this.props}/>)}/>
    <Route path='/single/:id' render={(props) => (<Single {...this.props}/>)}/>
    </Switch>

I can see the value of my params in react dev tools. but i can't access it in this.props.match.params.. enter image description here

Upvotes: 2

Views: 3385

Answers (1)

Lafi
Lafi

Reputation: 1342

It looks like you're debugging the state of a Component but not the component props that you are working on (there is a State label above the screen shot)?

Upvotes: 1

Related Questions