It depends on your app's style. If it is a simple app where component two needs to access component one's variables props would be easy to use. However, as apps scale, you need to consider situations where component two needs to access a global state. Then, things change. Suppose your ComponentOne is the parent that contains & controls the state and ComponentTwo is the child and will only use the state passed from the parent.

Component1.js

import React from 'react';
import ComponentTwo from "./yourcomponent2directory.js"

const ComponentOne = () => {

varOne = Mike;
varTwo = Tyson;

return
(
<div>
<ComponentTwo varOne={varOne} varTwo={varTwo}/>
</div>
)}

export default ComponentOne

ComponentTwo.js

import React from 'react';
import ComponentOne from '../OtherFolder/';

const ComponentTwo = (props) => {

return(
<div>
<p>{props.varOne}, {props.varTwo}</p>
</div>
)}

export default ComponentTwo

or you can destructure props like...

const ComponentTwo = ({varOne,varTwo}) => {

return(
<div>
<p>{varOne}, {varTwo}</p>
</div>
)}

export default ComponentTwo
Answer from Ahmet Ulutaş on Stack Overflow
🌐
React
react.dev › learn › passing-data-deeply-with-context
Passing Data Deeply with Context – React
You can’t do it with props alone. This is where context comes into play. You will do it in three steps: Create a context. (You can call it LevelContext, since it’s for the heading level.) Use that context from the component that needs the data.
🌐
Medium
medium.com › @zachlandis91 › react-share-global-data-between-components-without-props-9f24abbcf208
React: Share “Global” Data Between Components Without Props | by Zach Landis | Medium
March 20, 2023 - This scenario is referred to as prop drilling and it's generally advised to avoid it. ... A React Hook is essentially a template for a reusable function that can be called and used across components.
Discussions

How to pass data from one component to another in react without re-render or jsx like from a function using functional components
I am new to react and I am not getting any answers on this. I want to pass data from one functional component to another in react. However I do not want to render the child component. I just want t... More on stackoverflow.com
🌐 stackoverflow.com
React.js passing one components variables to another component and vice-versa
I've just started to learn react. If I have a component with two variables, what is the easiest way to access these in another component? Use props, useState, useContext? How would you do to use th... More on stackoverflow.com
🌐 stackoverflow.com
reactjs - How to send data from one component to another component in react without parent child relation - Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most · Connect and share knowledge within a single location that is structured and easy to search More on stackoverflow.com
🌐 stackoverflow.com
How can I pass data to a component without props in React?
in the question I mean this. Imagine that I want to show a component Called "Form" and inside of "Form" there is a list of components called "checkboxex" The normal way to do that is something lik... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How do I create a Context in React?
You can create a Context using React's createContext function, which returns a Context object with Provider and Consumer components.
🌐
pluralsight.com
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
How to Use React Context to Share Data between Components | ...
Can React Context replace state management libraries like Redux?
React Context can replace state management libraries for simple scenarios, but for complex state management, libraries like Redux might still be more appropriate.
🌐
pluralsight.com
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
How to Use React Context to Share Data between Components | ...
When should I use React Context?
React Context is ideal for sharing global data like themes, user information, or settings across multiple components without prop drilling.
🌐
pluralsight.com
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
How to Use React Context to Share Data between Components | ...
🌐
Codedamn
codedamn.com › news › react js
How can I share data between components in React.js?
October 18, 2023 - What is the Context API? React’s Context API provides a way to share values (data or functions) between components without having to explicitly pass props through every level of the component tree.
🌐
Stack Overflow
stackoverflow.com › questions › 73714583 › how-to-pass-data-from-one-component-to-another-in-react-without-re-render-or-jsx
How to pass data from one component to another in react without re-render or jsx like from a function using functional components
If I understand you correct, you want to pass data as prop to child component and do not want it to be re-rendered. Let's define a functional component using React.memo so that it will not be re-rendered unless its props changes.
Top answer
1 of 3
6

It depends on your app's style. If it is a simple app where component two needs to access component one's variables props would be easy to use. However, as apps scale, you need to consider situations where component two needs to access a global state. Then, things change. Suppose your ComponentOne is the parent that contains & controls the state and ComponentTwo is the child and will only use the state passed from the parent.

Component1.js

import React from 'react';
import ComponentTwo from "./yourcomponent2directory.js"

const ComponentOne = () => {

varOne = Mike;
varTwo = Tyson;

return
(
<div>
<ComponentTwo varOne={varOne} varTwo={varTwo}/>
</div>
)}

export default ComponentOne

ComponentTwo.js

import React from 'react';
import ComponentOne from '../OtherFolder/';

const ComponentTwo = (props) => {

return(
<div>
<p>{props.varOne}, {props.varTwo}</p>
</div>
)}

export default ComponentTwo

or you can destructure props like...

const ComponentTwo = ({varOne,varTwo}) => {

return(
<div>
<p>{varOne}, {varTwo}</p>
</div>
)}

export default ComponentTwo
2 of 3
6

There are three different communication b/w components based on their relation.

  1. Passing data from Parent-to-child

For passing data from parent to child component, we use props. Props data is sent by the parent component and cannot be changed by the child component as they are read-only.

  1. Passing data from Child-to-parent

For passing the data from the child component to the parent component, we have to create a callback function in the parent component and then pass the callback function to the child component as a prop. This callback function will retrieve the data from the child component. The child component calls the parent callback function using props and passes the data to the parent component.

  1. Passing data b/w Siblings

For passing data among siblings, there are multiple methods we can choose from as shown below:

  • Combination of the above two methods (callback and use of props).
  • Using Redux.
  • ContextAPI

#Copied from this link. You should check the given link and go through that how to pass when we have such relationship b/w components and when to use what.

🌐
React
react.dev › learn › sharing-state-between-components
Sharing State Between Components – React
Pass hardcoded data from the common parent. Add state to the common parent and pass it down together with the event handlers. This will allow the Accordion component to coordinate both Panels and only expand one at a time.
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › how-to-pass-data-from-one-component-to-other-component-in-reactjs
How to Pass Data from One Component to Another Component in ReactJS? - GeeksforGeeks
In this article, we will explore the different methods to pass data between components in ReactJS. The most common way to pass data between components is through props (short for properties). Props are read-only and allow you to pass information from a parent component to its child components.
Published   July 23, 2025
Find elsewhere
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
How to Use React Context to Share Data between Components | Pluralsight
April 24, 2024 - React Context allows you to pass data through a component tree without having to explicitly pass them through props or using any third-party library. This guide will only focus on how to use React Context in functional components as it is now ...
🌐
Stack Overflow
stackoverflow.com › questions › 55855813 › how-to-send-data-from-one-component-to-another-component-in-react-without-parent
reactjs - How to send data from one component to another component in react without parent child relation - Stack Overflow
import React, { Component } from 'react'; import Two from 'components/Two.jsx' import One from 'components/One.jsx' class Home extends Component { constructor(props){ super(props) this.state = { } this.one = React.createRef(); } getData = (data) => { this.one.current.finalClick(data); } render() { return ( <div> <Two shareData={this.getData} /> <One ref={this.one} /> </div> ); } } export default Home;
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Pass Data from an Input Field to another Component
February 27, 2024 - Hello, I have two components in React and want to pass data from 1. Inputfield to 2. URLconcatenate but I am not certain which is considered the parent or child, and how to pass the data along; as a state, as data, here’s what I have so far: Input.js import { useState } from 'react'; const Inputfield = () => { const [stockSymbol, setstockSymbol] = useState(''); const handleChange = event => { setstockSymbol(event.target.value); }; const handleClick = event => { ...
🌐
DEV Community
dev.to › turpp › passing-data-between-react-components-af7
Passing Data Between React Components - DEV Community
July 18, 2021 - Even if you do want to work around prop drilling, it's best to try applying component composition before reaching for Context, as mentioned in the Context React docs. Context is useful, but it has trade-offs.
🌐
Medium
medium.com › @babux1 › how-to-pass-state-data-from-one-component-to-another-in-react-js-9b4850887163
How to pass state data from one component to another in React.js | by Babux | Medium
February 21, 2023 - There are several ways to pass state to another component in React, including props, context, and callback functions.
🌐
freeCodeCamp
freecodecamp.org › news › pass-data-between-components-in-react
How to Pass Data and Events Between Components in React
June 8, 2021 - data is the data which we have to pass, and parentToChild is the name of the prop. Next, it's time to capture the data in the child component. And it's very simple. Here, there can be two cases. Case 1: If you are using a functional component, simply catch the parentToChild in the parameters. import React from 'react' export default function Child({parentToChild}) { return ( <div> {parentToChild} </div> ) }
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
How to Pass Data between React Components | Pluralsight
May 29, 2020 - Method 2: Use Redux by maintaining the states of all child components that you might need in a global store and obtain the data from said store. Method 3: Utilize React's Context API. Recently, many developers are choosing React's Context API ...
🌐
Medium
bloggerwomen.medium.com › how-do-you-connect-one-component-to-another-component-in-react-js-5b9ed85b1fcf
How do you connect one component to another component in React JS? | by BloggerWomen | Medium
March 16, 2023 - Though the framework has matured considerably since then, there doesn’t seem to yet be a firm ‘right’ way of doing things.In ReactJS, components can be connected to one another in various ways depending on your specific use case. Here are a few common methods. 1. Using Props: Props (short for properties) are used to pass data from a parent component to a child component.
🌐
Upmostly
upmostly.com › home › next.js › passing data between components
From A to B: Mastering Data Transfer Between Components in NextJS - Upmostly
March 22, 2023 - Context is another way of passing data, that allows you to pass data down the component tree without having to pass props manually at every level. For a more in-depth guide to Context in Next.js, check out this article.