function SentenceBuildA()
{
let pvalue="31/12/2024";
}
export default SentenceBuildA;
Need to another componnet
let childval=pvalue;
function SentenceBuildA()
{
let pvalue="31/12/2024";
}
export default SentenceBuildA;
Need to another componnet
let childval=pvalue;
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Naimish MakwanaPosted Jan 2, 2025, 4:55 AM
To pass the value from one component to another in React, you can use props. Here's how you can modify your code:
Define the value in the parent component and pass it as a prop to the child component.
Access the prop in the child component.
Here's an example:
Parent Component (e.g.,
ParentComponent.js)Child Component (e.g.,
SentenceBuildA.js)In this example, the
ParentComponentpasses thepvalueto theSentenceBuildAcomponent as a prop. TheSentenceBuildAcomponent then receives this prop and displays it.Thanks
Jayraj ChhayaPosted Dec 31, 2024, 12:31 PM
Hi amar Praveen,