import React, { PropTypes } from 'react';
import createMemoryHistory from 'history/lib/createMemoryHistory';
import { ArrowButton } from '../../components';
const history = createMemoryHistory();
const unlisten = history.listen((location, action) => {
console.log(action, location.pathname, location.state);
});
history.push('/home', { some: 'state' });
createMemoryHistory({
initialEntries: ['/'], // The initial URLs in the history stack
initialIndex: 0, // The starting index in the history stack
keyLength: 6, // The length of location.key
// A function to use to confirm navigation with the user. Required
// if you return string prompts from transition hooks (see below)
getUserConfirmation: null,
});
history.listen((location, action) => {
console.log(`The current URL is ${location.pathname}${location.search}${location.hash}`);
console.log(`The last navigation action was ${action}`);
});
const genericMessage = 'We have a problem.';
const RegistrationError = ({
reason,
returnToUrl,
goBack,
}) => (
<div className="registration-error">
<h2 className="register-title">Sorry!</h2>
<p>{ reason || genericMessage }</p>
{ !reason && (
<ArrowButton
onClick={() => returnToUrl(history.go(-1))}
>
Close
</ArrowButton>
我是Nodejs的新手,并且难以理解一些概念。我遇到的问题是,当我点击“关闭”按钮时,页面应重定向到之前查看的网站。但这不起作用。我究竟做错了什么?如果有人能指出我正确的方向。我已经检查了堆栈溢出的类似问题,这对我没有帮助。