freeCodeCamp/guide/russian/certifications/front-end-libraries/react/pass-props-to-a-stateless-f.../index.md

48 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Pass Props to a Stateless Functional Component
localeTitle: Передача реквизитов функциональному компоненту без состояния
---
## Передача реквизитов функциональному компоненту без состояния
### Подсказка 1
Определите имя с указанием даты в компоненте «Календарь» следующим образом:
```jsx
<CurrentDate date={Date()} />
```
\`
### Подсказка 2
Синтаксис prop.propName используется для отображения опоры.
### Решение
Назначьте опору с именем date в компоненте «Календарь» следующим образом и визуализируйте его в компоненте «Календарь», например:
```jsx
const CurrentDate = (props) => {
return (
<div>
<p>The current date is: {props.date}</p>
</div>
);
};
class Calendar extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h3>What date is it?</h3>
<CurrentDate date={Date()} />
</div>
);
}
};
```