react children Содержимое между тэгами компонента. Пример получения
Primary tabs
Пример:
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
const styles = theme => ({
formSection: {
marginBottom: 20,
}
});
function FormSection(props) {
const { classes, className } = props;
return (
<div className={`${classes.formSection} ${className || ''}`}>
{props.children}
</div>
);
}
FormSection.propTypes = {
classes: PropTypes.object.isRequired,
className: PropTypes.string,
};
export default withStyles(styles)(FormSection);
-- при этом в props.children окажется то, что мы разместим между тэгами компонента, например, в случае:
<FormSection className={"hold-border"}>
<h4> Привет</h4>
</FormSection>
там окажется значение:
<h4> Привет</h4>
- Log in to post comments
- 993 reads