MiguelSlv
MiguelSlv

Reputation: 15153

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:

Upvotes: 1

Views: 978

Answers (1)

Tholle
Tholle

Reputation: 112827

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,
    // ...
  };

  // ...
}

Upvotes: 1

Related Questions