Skip to content

Commit

Permalink
Update FieldTemplate.js: export internal components so you can reuse …
Browse files Browse the repository at this point in the history
…them
  • Loading branch information
Matej Mazur committed Aug 29, 2018
1 parent a573096 commit 0b87e63
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/templates/FieldTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,21 @@ if (process.env.NODE_ENV !== "production") {
displayLabel: PropTypes.bool,
fields: PropTypes.object,
formContext: PropTypes.object,
registry: PropTypes.shape({
widgets: PropTypes.objectOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
).isRequired,
templates: PropTypes.objectOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.object])
).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
};
}

function Label(props) {
export function Label(props) {
const { label, required, id } = props;
if (!label) {
// See #312: Ensure compatibility with old versions of React.
Expand All @@ -81,7 +92,7 @@ function Label(props) {
);
}

function Help(props) {
export function Help(props) {
const { help } = props;
if (!help) {
// See #312: Ensure compatibility with old versions of React.
Expand All @@ -93,7 +104,7 @@ function Help(props) {
return <div className="help-block">{help}</div>;
}

function ErrorList(props) {
export function ErrorList(props) {
const { errors = [] } = props;
if (errors.length === 0) {
return <div />;
Expand Down

0 comments on commit 0b87e63

Please sign in to comment.