我已将流星从1.5.2.2升级到1.6,我收到以下消息:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Route, Redirect } from 'react-router-dom';
const Public = ({ loggingIn, authenticated, component, ...rest, match, history }) => (
<Route
{...rest}
render={props => (
!authenticated ?
(React.createElement(component, { ...props, loggingIn, authenticated })) :
(<Redirect to="/events" />)
)}
/>
);
Public.propTypes = {
loggingIn: PropTypes.bool.isRequired,
authenticated: PropTypes.bool.isRequired,
component: PropTypes.func.isRequired,
history: PropTypes.object,
match: PropTypes.object,
};
export default Public;
我在stackoverflow中看到帖子,但我不知道如何应用或更改我的代码: https://marmelab.com/blog/2017/01/13/admin-on-rest-0-7.html#use-your-own-component
以下是Public.js文件:
.isdigit()
请帮助解决此问题。
答案 0 :(得分:0)
因为我使用了Cleverbeagle的PUP,并且他们已经更新了代码。 所以我改变了代码,它也适用于Meteor 1.6
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Route, Redirect } from 'react-router-dom';
const Public = ({ loggingIn, authenticated, component, path, exact, ...rest }) => (
<Route
path= {path}
exact={exact}
render={props => (
!authenticated ?
(React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) :
(<Redirect to="/events" />)
)}
/>
);
Public.propTypes = {
loggingIn: PropTypes.bool.isRequired,
authenticated: PropTypes.bool.isRequired,
component: PropTypes.func.isRequired,
};
export default Public;
答案 1 :(得分:0)
我知道很久以前就回答了这个问题,但最近我遇到了同样的问题,40分钟后我找到了解决办法:只需要将传播对象参数设置为最后一个参数。
在这种情况下:
const Public = ({ a, ...rest, b }) => (
<div>fail</div>
);
到
const Public = ({ a, b, ...rest }) => (
<div>success</div>
);
这对我有用