From f259f8c615edf87c82e1c246fbfa17c34a07e27e Mon Sep 17 00:00:00 2001 From: Lionel Date: Tue, 18 Dec 2018 15:57:44 +0100 Subject: [PATCH] fix: remove warning in development (#389) fixes #375 --- .../code-du-travail-frontend/pages/code-du-travail.js | 8 +++----- packages/code-du-travail-frontend/src/common/Answer.js | 8 ++++---- packages/code-du-travail-frontend/src/piwik.js | 3 ++- packages/code-du-travail-ui/doc/BreadCrumbs.mdx | 1 + packages/code-du-travail-ui/src/Article.js | 7 ++----- packages/code-du-travail-ui/src/BreadCrumbs.js | 5 +++-- packages/code-du-travail-ui/src/Section.js | 5 +---- 7 files changed, 16 insertions(+), 21 deletions(-) diff --git a/packages/code-du-travail-frontend/pages/code-du-travail.js b/packages/code-du-travail-frontend/pages/code-du-travail.js index 08d249a050..6a3c32d37a 100644 --- a/packages/code-du-travail-frontend/pages/code-du-travail.js +++ b/packages/code-du-travail-frontend/pages/code-du-travail.js @@ -65,11 +65,9 @@ class Fiche extends React.Component { -
- -
- +
+ +
} date={format(new Date(data._source.date_debut), "D MMMM YYYY", { locale: frLocale diff --git a/packages/code-du-travail-frontend/src/common/Answer.js b/packages/code-du-travail-frontend/src/common/Answer.js index 21275085ec..fff9c8b7e8 100644 --- a/packages/code-du-travail-frontend/src/common/Answer.js +++ b/packages/code-du-travail-frontend/src/common/Answer.js @@ -42,9 +42,9 @@ class Answer extends React.Component { const { router, title, - intro, - html, - children, + intro = null, + html = null, + children = null, footer, date, icon, @@ -78,7 +78,7 @@ class Answer extends React.Component { > {intro} - {html} + {html && {html}} {children}
+ Accueil, diff --git a/packages/code-du-travail-ui/src/Article.js b/packages/code-du-travail-ui/src/Article.js index fa9787b6c5..400b8691c8 100644 --- a/packages/code-du-travail-ui/src/Article.js +++ b/packages/code-du-travail-ui/src/Article.js @@ -85,7 +85,7 @@ const Article = ({ />
-
{children}
+ {children &&
{children}
} ); }; @@ -94,10 +94,7 @@ Article.propTypes = { /** article title */ title: PropTypes.string.isRequired, /** article content */ - children: PropTypes.oneOfType([ - PropTypes.element, - PropTypes.arrayOf(PropTypes.element) - ]).isRequired, + children: PropTypes.node, date: PropTypes.string, sourceType: PropTypes.string, icon: PropTypes.func, diff --git a/packages/code-du-travail-ui/src/BreadCrumbs.js b/packages/code-du-travail-ui/src/BreadCrumbs.js index cd9ae7f605..40fe7aa6a7 100644 --- a/packages/code-du-travail-ui/src/BreadCrumbs.js +++ b/packages/code-du-travail-ui/src/BreadCrumbs.js @@ -14,14 +14,15 @@ const BreadCrumbs = ({ entries }) => ( ); BreadCrumbs.propTypes = { - entries: PropTypes.arrayOf(PropTypes.element) + entries: PropTypes.node }; BreadCrumbs.defaultProps = { entries: [ Accueil - + , + "end" ] }; diff --git a/packages/code-du-travail-ui/src/Section.js b/packages/code-du-travail-ui/src/Section.js index df75157104..3c6586bb5d 100644 --- a/packages/code-du-travail-ui/src/Section.js +++ b/packages/code-du-travail-ui/src/Section.js @@ -22,10 +22,7 @@ const Section = ({ light, dark, style, children }) => { }; Section.propTypes = { - children: PropTypes.oneOfType([ - PropTypes.element, - PropTypes.arrayOf(PropTypes.element) - ]).isRequired, + children: PropTypes.node.isRequired, style: PropTypes.object, light: PropTypes.bool, dark: PropTypes.bool