fix(jsx): prevent bootstrap from injecting props to react primitive
This commit is contained in:
committed by
Stuart Taylor
parent
484dc743dc
commit
675438b075
@ -11,6 +11,7 @@ import {
|
|||||||
|
|
||||||
import navLinks from './links.json';
|
import navLinks from './links.json';
|
||||||
import AvatarPointsNavItem from './Avatar-Points-Nav-Item.jsx';
|
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';
|
const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg';
|
||||||
|
|
||||||
@ -82,14 +83,16 @@ export default class extends React.Component {
|
|||||||
renderMapLink(isOnMap, toggleMapDrawer) {
|
renderMapLink(isOnMap, toggleMapDrawer) {
|
||||||
if (isOnMap) {
|
if (isOnMap) {
|
||||||
return (
|
return (
|
||||||
<li role='presentation'>
|
<NoPropsPassthrough>
|
||||||
<a
|
<li role='presentation'>
|
||||||
href='#'
|
<a
|
||||||
onClick={ this.handleMapClickOnMap }
|
href='#'
|
||||||
>
|
onClick={ this.handleMapClickOnMap }
|
||||||
Map
|
>
|
||||||
</a>
|
Map
|
||||||
</li>
|
</a>
|
||||||
|
</li>
|
||||||
|
</NoPropsPassthrough>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
12
common/app/utils/No-Props-Passthrough.jsx
Normal file
12
common/app/utils/No-Props-Passthrough.jsx
Normal file
@ -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
|
||||||
|
};
|
Reference in New Issue
Block a user