2016-10-26 2 views
1

현재 Scala, Play 프레임 워크 및 React 샘플 코드로 재생 중이며 ES6 모듈 시스템을 사용하지 않고 브라우저에서로드하도록 다음 코드를 변환하는 동안 문제가 발생합니다. 즉, export default을 사용할 수 없습니다.ES6 모듈없이 반응

export default없이 클라이언트 측에서로드 할 수 있도록 ES6에서 다음을 다시 작성하는 방법은 무엇입니까? 이 클래스를 반올림하여 render을 반환하는 함수로 분해해야합니까? 당신은 여기에 전체 일을 다시 작성 ... 할거야

export default function form({ 
    fields: defaultFds = [], 
    validate: defaultVal =() => ({}), 
} = {}) { 
    return (WrappedClass) => class Form extends React.Component { 
    static defaultProps = { 
     fields: defaultFds, 
     validate: defaultVal, 
    } 

    static childContextTypes = { 
     form: PropTypes.object, 
     fields: PropTypes.object, 
    } 

    static propTypes = { 
     fields: PropTypes.array, 
     validate: PropTypes.func, 
     value: PropTypes.object, 
     onChange: PropTypes.func, 
     onValidate: PropTypes.func, 
    } 

    state = { 
     touched: {}, 
     errors: {}, 
     valid: undefined, 
    } 

    render() { 
     const { value, onChange, onValidate, validate, fields, ...otherProps } = this.props; 
     return <WrappedClass {...otherProps} {...this.generatedProps()} />; 
    } 
    } 
} 

답변

0

당신이 ES6를 사용할 수없는 경우 당신은 export default가보다 걱정이 더 있기 때문에 - () =>에 정의 된 모든 기능은 할 필요를 다시 쓰여지고 JSX를 사용할 수 없을 것입니다.

주제에 대해 React docs을 읽으셨습니까?

+0

그래, 나는 그것을 깨달았다 :(. webpack을 통합하는 방법을 알아 냈다. – nixgadgets

관련 문제