First post, please have mercy.
Map function returns no error, yet categories which I attempt to map wont load. console.log - returns respective paths in desired format eg. "/all" ; "/clothes" and "/tech". I tried getting rid of console.log, return (), changing "" to '', restarting the server with no result.
CategoryPage element itself loads when loading from /Categories, so the "hardcoded" routing works. All the other routes work fine too.
I also tried to put the entire map bit outside render and console.log it to see if does anything at all and yes it does - it returned bunch of data in a weird format, but that is (I think) due to JSX.
Desired output: to load CategoryPage when accessing /all, /clothes and /tech with appropriate props passed down.
I really do appreciate your time trying to help me <3
render() {
const pathArr = Object.entries(this.props.categories);
console.log(pathArr);
return (
<ApolloProvider client={client}>
<Router>
<div className="App">
<NavBar />
<div className="content">
<Switch>
{pathArr.map((elem) => {
return (
(
<Route
key={elem}
exact
path={`"/${elem[1].name}"`}
>
<CategoryPage category={elem[1].name} />
</Route>
) && console.log(`"/${elem[1].name}"`)
);
})}
<Route path="/Categories">
<CategoryPage />
</Route>
<Route exact path="/cart">
<Cart />
</Route>
<Route exact path="/product/:id" component={PDP} />
</Switch>
</div>
</div>
</Router>
</ApolloProvider>
);
}