From 675438b0750dc3289ec873ea1f94dce71f215b6a Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Thu, 27 Oct 2016 16:32:13 -0700 Subject: [PATCH] fix(jsx): prevent bootstrap from injecting props to react primitive --- common/app/components/Nav/Nav.jsx | 19 +++++++++++-------- common/app/utils/No-Props-Passthrough.jsx | 12 ++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 common/app/utils/No-Props-Passthrough.jsx diff --git a/common/app/components/Nav/Nav.jsx b/common/app/components/Nav/Nav.jsx index 2db4dfb6d32..feac803b52c 100644 --- a/common/app/components/Nav/Nav.jsx +++ b/common/app/components/Nav/Nav.jsx @@ -11,6 +11,7 @@ import { import navLinks from './links.json'; import AvatarPointsNavItem from './Avatar-Points-Nav-Item.jsx'; +import NoPropsPassthrough from '../../utils/No-Props-Passthrough.jsx'; const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg'; @@ -82,14 +83,16 @@ export default class extends React.Component { renderMapLink(isOnMap, toggleMapDrawer) { if (isOnMap) { return ( -
  • - - Map - -
  • + +
  • + + Map + +
  • +
    ); } return ( diff --git a/common/app/utils/No-Props-Passthrough.jsx b/common/app/utils/No-Props-Passthrough.jsx new file mode 100644 index 00000000000..d0ab31cd7f0 --- /dev/null +++ b/common/app/utils/No-Props-Passthrough.jsx @@ -0,0 +1,12 @@ +import { PropTypes } from 'react'; + +// use when passing a react primitive element as a child to a +// react-boostrap component that will inject props +// using cloneElement +export default function NoPropsPassthrough({ children }) { + return children; +} + +NoPropsPassthrough.propTypes = { + children: PropTypes.element +};