Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix React 15.5.3 PropTypes deprecated warning while using react-transition-group

guys! Did anybody got "Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead." while using React 15.5.3 "react-transition-group/CSSTransitionGroup" add-on.

It looks like this addon uses old PropTypes. Do somebody know how to avoid this Warning for this add-on?

like image 981
Dmytro Zhytomyrsky Avatar asked Oct 29 '22 09:10

Dmytro Zhytomyrsky


2 Answers

It has been deprecated After React version 15.5. Hence you need to install it separately.,
Install: npm install prop-types

import React from 'react';
import PropTypes from 'prop-types';

class Component extends React.Component {
  render() {
    return <div>{this.props.text}</div>;
  }
}

Component.propTypes = {
  text: PropTypes.string.isRequired,
};

Edit: You need to get updated package for add-on compatible with react latest updates. It the package is yet not updated, you can make changes to them ypurself.

like image 193
Ved Avatar answered Dec 01 '22 03:12

Ved


This bug fixed automatically when I updated "react-transition-group" to latest version. It looks that the npm package now works on PropTypes from 'prop-types'.

like image 45
Dmytro Zhytomyrsky Avatar answered Dec 01 '22 04:12

Dmytro Zhytomyrsky