ReactTraining / react-history

Manage session history with React
266 stars 23 forks source link

TypeError: Cannot read property 'oneOf' of undefined #26

Open ltsharma opened 6 years ago

ltsharma commented 6 years ago

Using import { Push } from "react-history/Actions";

**Error** TypeError: Cannot read property 'oneOf' of undefined > 8 | var action = exports.action = _react.PropTypes.oneOf(['PUSH', 'REPLACE', 'POP']);
gitgrimbo commented 6 years ago

Related to incompatibility with React 16 I believe. See #30.

I'm currently trying this as a workaround.

import "./react-history-compat";
import History from "react-history/BrowserHistory";

where "./react-history-compat" is

import React from "react";
import PropTypes from "prop-types";
React.PropTypes = PropTypes;

Or use the version published by @researchgate at https://github.com/researchgate/react-history/releases/tag/v0.19.1.

npm i --save @researchgate/react-history

import { BrowserHistory as History } from "@researchgate/react-history"