🌐
React
react.dev › learn › passing-props-to-a-component
Passing Props to a Component – React
Don’t try to “change props”. ... learn about in State: A Component’s Memory. To pass props, add them to the JSX, just like you would with HTML attributes....
🌐
React
legacy.reactjs.org › docs › components-and-props.html
Components and Props – React
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen. The simplest way to define a component is to write a JavaScript ...
Discussions

reactjs - Add more props to JSX.Element in typescript - Stack Overflow
When you have already called the ... get a JSX.Element which is not callable. You want to be passing a callable component. If this is react-router-dom I would recommend using the component prop instead of the children prop since they behave differently. We want to say that our component ... More on stackoverflow.com
🌐 stackoverflow.com
State vs. Props and how to stop confusing them?
Props are passed to the component, so they are external data that usually comes from another component that renders it. State, on the other hand, is internal to a component and is usually managed by it. State from one component can be passed to another component via its props, much like a function could call another function and give it arguments. Define props for a component when you want it receive data from whoever will render it. Use state in a component when you want to have control over some piece of data that it will manage/update. More on reddit.com
🌐 r/reactjs
5
2
September 21, 2019
Understanding State and Props in React – Hacker Noon

Charming, concise, and even has code examples. I wish more articles were like this.

More on reddit.com
🌐 r/javascript
1
3
April 19, 2017
props!!!props!!! Anyone???

If you extend an object you want to construct that parent object. What you pass to that object depends on that object's needs. You could construct it without props, or maybe you need a lot more. If you don't need the props then you can skip on them.

Simple example:

class Vehicle {
constructor(props) {
this.wheels = props.wheels;
this.doors = props.doors;
this.airborne = props.airborne;
}
}

class Car extends Vehicle {
constructor(props) {
super({
...props,
airborne: false
});
}
}

const car = new Car({
doors: 4,
wheels: 4,
});

console.log(car); // {wheels: 4, doors: 4, airborne: false}

Sometimes you don't need the super call to have any parameters, and that's fine.

More on reddit.com
🌐 r/reactjs
12
0
October 25, 2018
🌐
W3Schools
w3schools.com › react › react_props.asp
React Props
React props can be of any data type, including variables, numbers, strings, objects, arrays, and more. Strings can be sent inside quotes as in the examples above, but numbers, variables, and objects need to be sent inside curly brackets.
🌐
React
legacy.reactjs.org › docs › jsx-in-depth.html
JSX In Depth – React
You can also refer to a React component using dot-notation from within JSX. This is convenient if you have a single module that exports many React components. For example, if MyComponents.DatePicker is a component, you can use it directly from JSX with: import React from 'react'; const MyComponents = { DatePicker: function DatePicker(props) { return <div>Imagine a {props.color} datepicker here.</div>; } } function BlueDatePicker() { return <MyComponents.DatePicker color="blue" />;}
🌐
React Native
reactnative.dev › docs › props
Props · React Native
February 20, 2026 - You can put any JavaScript expression inside braces in JSX. Your own components can also use props. This lets you make a single component that is used in many different places in your app, with slightly different properties in each place by ...
🌐
Next.js
nextjs.org › learn › react-foundations › displaying-data-with-props
React Foundations: Displaying Data with Props | Next.js
You need a way to tell React that this is a JavaScript variable. To use the title prop, add curly braces {}. These are a special JSX syntax that allows you to write regular JavaScript directly inside your JSX markup.
🌐
DEV Community
dev.to › a1guy › react-components-props-and-jsx-a-beginners-guide-50ae
React Components, Props, and JSX: A Beginner’s Guide - DEV Community
August 15, 2025 - Inside TodoList, we use the JavaScript .map() method to loop through the array and return one ... The key prop is a special React attribute that helps React identify which list items have changed, been added, or removed. It should be unique for each item in the list — here we use the id. This approach is preferred in React because .map() creates a new array of elements, which is exactly what JSX needs to render the list.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-props-in-react
How to Use Props in React
November 15, 2021 - Read this article). We use props in React to pass data from one component to another (from a parent component to a child component(s)). Props is just a shorter way of saying properties.
Find elsewhere
🌐
DEV Community
dev.to › rossonevan › react-jsx-components-and-props-ndo
React: JSX, Components, and Props - DEV Community
August 3, 2022 - NOTE: Props cannot be passed between ... </div> ) } Whenever we want to call our props into our JSX, we must contain them inside {} then use props....
🌐
SheCodes
shecodes.io › athena › 60069-understanding-react-props-examples-and-how-they-work
[React] - Understanding React Props: Examples and How They | SheCodes
How do I pass a state variable declared in one component to another component · React state variable props · Asked 2 years ago in React by Monica · This component should render the text Directors Page in an <h1>, and make a new <div> for each director. The <div> should contain the director's name and a <ul> with a list of their movies · render component structure Array map JSX · Asked 2 years ago in React by hassan · using react Inside of your ‘App’ class ‘render’ method, return a div with your basic information for example name, number, date of birth and etc.
🌐
GUVI
guvi.in › blog › mern › how to use props in react [in 3 simple steps]
How to use Props in React [in 3 simple steps]
October 7, 2025 - To use props, we first pass the “props” keyword as an argument into our function which can be seen as follows. ... Here we are not declaring the variables before rather we are using them directly into our JSX template i.e., into our <li> element.
🌐
Robin Wieruch
robinwieruch.de › react-pass-props-to-component
How to use Props in React - Robin Wieruch
March 25, 2022 - Entering React props — where you can pass data from one component to another in React — by defining custom HTML attributes to which you assign your data with JSX’s syntax: ... import * as React from 'react'; const App = () => { const greeting ...
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › different-ways-to-access-props-inside-a-component-in-react
Different ways to access props inside a Component in React - GeeksforGeeks
July 23, 2025 - This approach is similar to context API approach. In this we start with creating context object and using ContextObject.Provider to provide the prop values from parent component to child component.
🌐
Medium
medium.com › @andrewasmit › passing-props-in-react-370e6c4c799b
Passing Props in React.js. When I first started React, I ran into… | by Andrew Smit | Medium
December 5, 2022 - Destructuring the props is also ... the component. ... We can destructure the props being passed in by using curly braces around the name of each prop being passed in from the parent component....
🌐
Built In
builtin.com › articles › react-props
React Props Explained With Examples | Built In
December 18, 2023 - Now, the ChildComponent has a property and a value. Next, we need to pass it via props. Let’s take the “I’m the 1st child!” string and pass it by using props.
🌐
Simplilearn
simplilearn.com › home › resources › software development › understand all about props in react js
Understand all about Props In React Js | Simplilearn
February 14, 2026 - Props is short for properties in ReactJS & they are used to pass data between React components. React's data flow between components is uni-directional. Read More to understand better.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Top answer
1 of 3
2

Well the other way you can do is using Context API. Have a look at https://reactjs.org/docs/context.html#when-to-use-context for more understanding

What I would do is I would create a custom type that would contain the user id and then use this type to create react context.

Now next step would be use this context and create a provider and then render necessary components inside this context provider. You can then consume this context in any of the child component that is at any deep level nested in this custom created context and you can get the user id.

For eg.

Create custom context type and react context:

export type MyContextType = {
    userId: number
}

export const MyContext = React.createContext<MyContextType>(undefined!);

Now use provider and pass the initial value in your main/root file

const context: MyContextType = {
     userId: 1 (I am assuming you would get this from API response or local storage)
};
<MyContext.Provider value={context}>
    ...nested components
    <MyComponent />
</MyContext.Provider>

and then in any of your nested component you can get this context and the value using:

class MyComponent extends React.Component<MyComponentProps, State> {
    static contextType = MyContext;
    context!: React.ContextType<typeof MyContext>;

    render() {
       console.log(this.context.userId); // You should be able to see 1 being printed in the console.
    }
}
2 of 3
2

Component vs. Element

There is a difference between passing the component itself as the children prop:

<PrivateRoute>
  {MyComponent}
</PrivateRoute>

and passing an instance of the component:

<PrivateRoute>
  <MyComponent/>
</PrivateRoute>

The type children: JSX.Element applies to the second case and that is why you get the error:

JSX element type 'Component' does not have any construct or call signatures.

When you have already called the component through JSX like <MyComponent/> then you just get a JSX.Element which is not callable.


Typing the Component

You want to be passing a callable component. If this is react-router-dom I would recommend using the component prop instead of the children prop since they behave differently.

We want to say that our component can take the standard RouteComponentProps and also a user prop.

The PrivateRoute itself should take all of the RouteProps like to, exact, etc. But we will require a component prop with our modified type.

In order to call the component with our extra prop, we could use an inline render function render={props => <Component {...props} user={user} />}. We need to destructure it with an uppercase name in order to call it. We could also move the authentication logic into a higher-order component and use component={withUser(component)}.


Other Issues

We are going to be including this PrivateRoute alongside other Route components. So we want to render the Redirect only when we are actually on this Route. In other words, it should be a replacement of the component rather than a replacement of the Route. Otherwise traffic to other non-private routes will get inadvertently redirected.

You probably don't want to Redirect to the login page until after loading has finished. You can render a loading spinner or nothing while waiting for completion.

I'm not sure why there is so much checking and assertion on user. You should be able to do const user = data?.me; and get either a PartialUser or undefined.


Code

import React from "react";
import { Redirect, Route, RouteComponentProps, RouteProps, Switch } from "react-router-dom";

type PartialUser = {
    id: number;
    username: string;
    email: string;
};

declare function useMeQuery(): { error: any; loading: boolean; data?: { me: PartialUser } }

type ComponentProps = RouteComponentProps & {
    user: PartialUser;
}

type Props = RouteProps & {
    component: React.ComponentType<ComponentProps>;
    // disallow other methods of setting the render component
    render?: never;
    children?: never;
};

const PrivateRoute = ({ component: Component, ...rest }: Props) => {
  const { data, error, loading } = useMeQuery();

  const user = data?.me;

  return (
    <Route
      {...rest}
      render={(props) => {
        if (user) {
          return <Component {...props} user={user} />;
        } else if (loading) {
          return null; // don't redirect until complete
        } else {
          return <Redirect to="/login" />;
        }
      }}
    />
  );
};

const MustHaveUser = ({user}: {user: PartialUser}) => {
    return <div>Username is {user.username}</div>
}

export const Test = () => (
    <Switch>
        <Route path="/home" render={() => <div>Home</div>} />
        <PrivateRoute path="/dashboard" component={MustHaveUser} />
    </Switch>
)

Typescript Playground Link

🌐
ScholarHat
scholarhat.com › home
Props in React
September 11, 2025 - When a component is rendered in React, an attribute's value is assigned to specify a prop. With the help of props, we are able to build reusable elements that can be rendered with new information each time they are utilized.