Error with Params on first load of page on Real Device

Hello everyone,

I’m more or less new to this stuff, I’m working on my App for a school project about 2 months ago. Now I’m having a issue with params in URLs, I’ll explain better possible.

I have the issue following links using or using onClick={ () => {history.push (’/groups/xxxx’); }, the issue is that I can’t read parameter with useParams or with RouteComponentProps (match.params.groupid).

Here is my code from Router:

	<SideMenu />
		<IonRouterOutlet id="main">
			<Route path="/edit-user-profile" exact >
			<Route path="/messages" exact component={Messages} />
			<Route path="/links" exact component={Links} />
			<Route path="/users" exact component={Users} />
			<Route path="/users/detail/:userid" component={User} />
			<Route path="/groups" exact component={Groups} />
			<Route path="/groups/detail/:groupid" component={Group} />
			<Redirect path="" to="/groups" exact/>

The problem occurs ONLY on real devices (both Android and iOS), in web browser on my MAC it all works well. In the real devices, If I debug it and reload the page it works, but when I follow the link I got blank page.

Here is the code when I’m trying to read the param:

interface GroupIdProps extends RouteComponentProps<{
    groupid: string;
}> {}
const Group: React.FC<GroupIdProps|null> = ({match}) => {

    const groupid = match.params.groupid; // NULL


Sorry for my English and thanks all of you!

For the path /groups/xxxx then the Route should be

<Route path="/groups/:groupid" exact component={Groups} />

IF you really are trying to access the route

<Route path="/groups/detail/:groupid" component={Group} />

Then your code should be


Sorry for my mistake Aaron,

I want to use the path /groups/detail/xxx for a group with id = xxx, and I’m using links like that.

So my route is:

<Route path="/groups/detail/:grouped" component={Group} />

Maybe you need another info to help me, ask what you need Aaron,

thanks a lot!

please fork this project and put the code in so I can get a better understanding of the issue.

My project is Ionic + React, should I create a new one and give access to you? Do you want to see all my code?

just fork the link and add just the component that is not working and the router

I hope I’ve done it Ok:

import React from "react";
import {
} from "@ionic/react";
import { IonReactRouter } from "@ionic/react-router";
import { Route, Redirect } from "react-router-dom";
import { RouteComponentProps, Switch } from "react-router";

/* Core CSS required for Ionic components to work properly */
import "@ionic/react/css/core.css";

/* Basic CSS for apps built with Ionic */
import "@ionic/react/css/normalize.css";
import "@ionic/react/css/structure.css";
import "@ionic/react/css/typography.css";

/* Optional CSS utils that can be commented out */
import "@ionic/react/css/padding.css";
import "@ionic/react/css/float-elements.css";
import "@ionic/react/css/text-alignment.css";
import "@ionic/react/css/text-transformation.css";
import "@ionic/react/css/flex-utils.css";
import "@ionic/react/css/display.css";

const App: React.FunctionComponent = () => {
  return (
            <Route path="/groups/detail/:groupid" component={GroupDetail} />{" "}
            <Route path="/groups" exact component={Groups} />
            <Redirect from="/" to="/groups" exact />

export default App;

const Groups: React.FC = () => {
  console.log("Rendering GROUPS");

  return (
          Group aaa
          Group bbb

interface GroupDetailProps
  extends RouteComponentProps<{
    groupid: string;
const GroupDetail: React.FC<GroupDetailProps> = ({ match }) => {
  console.log("Rendering GroupDetail " + match?.params?.groupid);

  return (
          <IonButtons slot="start">
            <IonBackButton />
          <IonTitle>{"DETAIL PAGE"}</IonTitle>
        <h1>Group { match?.params?.groupid}</h1>

The label do the trick.

Thank you so so much Aaron, you’r the best!!

1 Like