【发布时间】:2018-07-31 07:19:03
【问题描述】:
我无法在我的管道中包含 babel-preset-stage-3。传播运算符有什么替代方案吗?
我正在尝试编译以下代码,但出现语法错误:
const PrivateRoute = ({ component: Component, ...rest }) => (
<Route
{...rest}
render={props =>
fakeAuth.isAuthenticated ? (
<Component {...props} />
) : (
<Redirect
to={{
pathname: "/login",
state: { from: props.location }
}}
/>
)
}
/>
);
【问题讨论】:
-
简单地使用两个参数怎么样?
-
@Bergi 可以传入任意数量的参数,由函数的用户指定。
-
我的意思是
const privateRoute = (component, rest) => …
标签: javascript reactjs ecmascript-6 react-router