ReactFix
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • React
  • React Native
  • Programming
  • Object Oriented Programming

Saturday, December 10, 2022

[FIXED] How get props location in ReactJS

 December 10, 2022     javascript, react-props, reactjs, redux   

Issue

How get location from props?

function TobaccoLine({ match, props  }) {
   const activeTab = useSelector(state => props.location.state ? props.location.state.activeTab : 0);
...
}

Props are undefined.

ReactJS v16.13.1


Solution

You can use the location instead of props.

function TobaccoLine({ match, location }) {
   const activeTab = useSelector(state => location.state ? location.state.activeTab : 0);
...
}


Answered By - Mediator
Answer Checked By - - Gilberto Lyons (ReactFix Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post Home

Featured Post

Is Learning React Difficult?

React is difficult to learn, no ifs and buts. React isn't inherently difficult to learn. It's a framework that's different from ...

Total Pageviews

Copyright © ReactFix