2017-10-20 9 views
0

그래서 class App과 함께 사용자 정의 구성 요소가 있지만 여전히 문제가 있습니다. 그것은 쉬운 일이라고 확신하지만, 나 같은 사람들을 위해서, 나는 그것을 알아 내지 못하고있다. 기본적으로, 내 코드는 다음과 같습니다반응에서 기묘한 구문 오류

(app.jsx) :

그래도, 나는이 오류가 무엇입니까 실행할
import React from 'react'; 
import '../styles/index.scss'; 

const EventCalendar = require('react-event-calendar'); 

const events = [ 
    { 
     start: '2015-07-20', 
     end: '2015-07-02', 
     eventClasses: 'optionalEvent', 
     title: 'test event', 
     description: 'This is a test description of an event', 
    }, 
    { 
     start: '2015-07-19', 
     end: '2015-07-25', 
     title: 'test event', 
     description: 'This is a test description of an event', 
     data: 'you can add what ever random data you may want to use later', 
    }, 
]; 

export default class App extends React.Component { 
    render() { 
    return (
     <div> 
     <h1>It Works!</h1> 
     <p>This React project just works including <span className="redBg">module</span> local styles.</p> 
     <p>Enjoy!</p> 

       <EventCalendar 
        month={7} 
        year={2017} 
        events={events} 
        onEventClick={(target, eventData, day)} => console.log(eventData) 
        /> 

     </div> 
    ) 
    } 
} 

:

enter image description here

사람이 도움을 할 수 있습니까?

감사합니다.

업데이트 : 나는 제안 구문 오류를 수정하고 나는이 얻을 지금, 나는 this project의 샘플 프로젝트를 사용하고 반응에서 새로운 것을 배우고이를 사용하지만,하려고으로 스크린 샷에서와 같이

enter image description here

+2

귀하의'onEventClick = {(대상, EVENTDATA, 일)} => CONSOLE.LOG (EVENTDATA)'라인이 가지고있는 잘못된 위치에 곱슬 폐쇄 , 로그 뒤에 있어야합니다. 이것이이 코드에서 볼 수있는 유일한 오류입니다. – loganfsmyth

+0

불변의 에러는, 올바르게 임포트되지 않은 컴퍼넌트를 렌더링하려고하면 (자) 발생합니다. 이 경우 [react-event-calendar] (https://github.com/dptoot/react-event-calendar) 패키지가 꽤 오래되어 지원되지 않는 것처럼 보입니다. 렌더링에서 해당 구성 요소를 제거하면 응용 프로그램이 작동합니다. 새로운 응용 프로그램을 찾는 것이 좋습니다. –

+0

@AustinGreco - 시작한 일정 캘린더 구성 요소 또는 반응 베벨 시작 앱이란 무엇입니까? 어느 쪽도 오래되었던 것처럼 보이지 않았고 최근에 활동했다. 구성 요소 렌더링을 전혀 쓸모 없게 변경하려고했습니다. – Mark

답변

1

웹팩 때로는 미묘한 될 수있는 오류를 구축 :

import React from 'react'; 
import '../styles/index.scss'; 

const EventCalendar = require('react-event-calendar'); 

const events = [ 
    { 
     start: '2015-07-20', 
     end: '2015-07-02', 
     eventClasses: 'optionalEvent', 
     title: 'test event', 
     description: 'This is a test description of an event', 
    }, 
    { 
     start: '2015-07-19', 
     end: '2015-07-25', 
     title: 'test event', 
     description: 'This is a test description of an event', 
     data: 'you can add what ever random data you may want to use later', 
    }, 
]; 

export default class App extends React.Component { 
    render() { 
    return (
     <div> 
     <h1>It Works!</h1> 
     <p>This React project just works including <span className="redBg">module</span> local styles.</p> 
     <p>Enjoy!</p> 

       <EventCalendar 
        month={7} 
        year={2017} 
        events={events} 
        onEventClick={(target, eventData, day) => console.log(eventData)} // the closing curly brace 
        /> 

     </div> 
    ) 
    } 
}