Изучаем Props
This commit is contained in:
+17
-3
@@ -1,10 +1,24 @@
|
||||
// удаляем все, оставляя лишь пустую функцию App ниже
|
||||
import styles from './styles/App.module.scss'
|
||||
|
||||
function Person({ name, age }) {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<p>Имя: {name}</p>
|
||||
<p>Возраст: {age}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const options = {title:'Меню', width: 100, height: 200}
|
||||
let {width, title, height} = options;
|
||||
console.log(title);
|
||||
console.log(width);
|
||||
console.log(height);
|
||||
return (
|
||||
<>
|
||||
{/* Добавьте тестовый контент для проверки */}
|
||||
<h1>Hello, React!</h1>
|
||||
<Person name="Alex" age={28} />
|
||||
<Person name="Bob" age={35} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user