react-form-controlled
Version:
Intuitive react forms for building powerful applications
30 lines (24 loc) • 671 B
JavaScript
import PropTypes from 'prop-types';
import Element from './Element';
export default class Last extends Element {
render() {
const { children, render } = this.props;
const [index] = this.getIndexes();
const [total] = this.getTotals();
if (total === undefined) {
throw new Error('Total is not set for parent fieldset');
}
if (index < total - 1) {
return null;
}
if (typeof render === 'function') {
return this.replaceChildren(render({ index, total }));
}
return this.replaceChildren(children);
}
}
Last.propTypes = {
render: PropTypes.func,
children: PropTypes.node
};
//# sourceMappingURL=Last.js.map