2017-11-03 2 views
0

에 나는 1.6 1.5.2.2에서 유성을 업그레이드하고 난 다음과 같은 메시지가 가지고있다 :ArrayExpression 오류시 업그레이드 1.5.2.2에서 1.6

/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:147:13: 
    imports/ui/components/Public.js: Property elements[3] of ArrayExpression expected node to be of a type 
    ["null","Expression","SpreadElement"] but instead got undefined 
    at validate 
    (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:147:13) 
    at validator 
    (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:57:7) 
    at Object.validate 
    (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/definitions/index.js:190:10) 
    at validate 
    (/home/mai/.meteor/packages/ecmascript/.0.9.0.l8rb8s.l2n4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-types/lib/index.js:505:9) 
    at Object.builder 
... 
... 

I에 유래의 게시물을 참조하지만 난 몰라 적용하거나 내 코드를 변경하는 방법 : Babel: Replacing ArrowFunctionExpression vs FunctionDeclaration in ExportDefaultDeclaration

다음은 Public.js 파일을 :

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; 

이 문제를 해결하는 데 도움이 바랍니다.

답변

0

저는 Cleverbeagle에서 PUP를 사용하고 있으며 코드를 업데이트했습니다. 그래서 내가 코드를 변경하고 또한 유성 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; 
0

와 함께 작동하지만 최근 같은 문제를 가지고 40 분 후 나는 해결책을 발견 : 만 설정해야합니다 퍼짐 객체 param을 마지막 param으로 사용합니다. 이 경우

는 :

const Public = ({ a, ...rest, b }) => (
 
    <div>fail</div> 
 
);

const Public = ({ a, b, ...rest }) => (
 
    <div>success</div> 
 
);

이 날

를 작동