Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
180
rated 0 times [  181] [ 1]  / answers: 1 / hits: 5123  / 4 Years ago, wed, december 2, 2020, 12:00:00

as you may get from the title, passing props in react is not working. And i don´t get why.


Main Ap Component


import './App.css';
import Licence from './Licence';

function App() {
return (
<>
<Licence>
test={"Test123"}
</Licence>
</>
);
}
export default App;

Other Component


import React from 'react';


const Licence = (props) => {
return (
<div>
<h1>name : {props.test}</h1>
</div>
)
}

export default Licence;

Problem
if i start the script and render the page, nothing is shown. What am I doing wrong?


More From » reactjs

 Answers
2

Licence component looks good to me!


All you have to do is change up how you set it up on App. Props need to be passed on the tag, like this:



import './App.css';
import Licence from './Licence';

function App() {
return (
<>
<Licence test={"Test123"} />
</>
);
}
export default App;


[#2187] Saturday, November 28, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
;