Ad
TypeError: Cannot Read Property 'string' Of Undefined When Adding Google-tag-manager To Reactjs Site
My site is build on react-static
,a framework based on reactjs
.
I follow the google guide for adding the react-google-tag-manager
to the project.
When i refresh page i get the following error on the browser, for GoogleTagManager module:
TypeError: Cannot read property 'string' of undefined
at
GoogleTagManager.propTypes = {
gtmId: React.PropTypes.string.isRequired,
It seams React as no long the Proptypes
property.
Enverioment:
- "react": "16.8.4",
- "react-google-tag-manager": "2.2.1",
Ad
Answer
prop-types
is its own package these days. It got moved to a separate package in v15.5.
import PropTypes from 'prop-types';
class GoogleTagManager extends React.Component {
static propTypes = {
gtmId: PropTypes.string.isRequired,
// ...
};
// ...
}
Ad
source: stackoverflow.com
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad