And*_*Hin 6 javascript ecmascript-6 reactjs react-router
我无法包含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 }
}}
/>
)
}
/>
);
Run Code Online (Sandbox Code Playgroud)
使用lodash.omit:
const PrivateRoute = (props) => {
const Component = props.component;
const rest = omit(props, ['component'])
return (
<Route
{...rest}
render={props =>
fakeAuth.isAuthenticated ? (
<Component {...props} />
) : (
<Redirect
to={{
pathname: "/login",
state: { from: props.location }
}}
/>
)
}
/>
);
}
Run Code Online (Sandbox Code Playgroud)