Are you first timer at Why not join us and start exchange your programming knowledge with everyone. Register today!

React - window is not defined issue

0 votes
added Mar 18 in React by lcjr First Warrant Officer (8,030 points)
// instead of window.location.pathname like we use for normal JS, add window && 
const current_path = window && window.location.pathname;
const path_arr = current_path.split("/");
const narrGroup = path_arr[2];


Please log in or register to response this reference. - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.