/
aprogrammer
/
react-basic-intro
Обзор
Документация
Войти
/
aprogrammer
/
react-basic-intro
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
intro-vite/src/components/ValidationPropsComponent.jsx
25 строк
614 B
aprogrammer-ru
init repo
23 дек 2024, 23:54
23 дек 2024, 23:54
ed05041
Код
Авторство
О чём код?
//a component with a prop that use constraint of propTypes = string, number // and a default value of 10 import React from 'react'; import PropTypes from 'prop-types'; //importing prop-types const ValidationPropsComponent = ({ inputValue, isTrue }) => { return ( <div> <h1>Значение: {inputValue}</h1> </div> ); }; ValidationPropsComponent.propTypes = { inputValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, isTrue: PropTypes.bool }; ValidationPropsComponent.defaultProps = { isTrue: false }; export default ValidationPropsComponent;