简体   繁体   English

React中的奇怪语法错误

[英]Odd syntax error in React

So I have custom component with the class App , but still having issues. 因此,我在class App有自定义组件,但是仍然有问题。 Am sure it is something easy, but for the likes of me, I am not figuring it out. 肯定这很容易,但是对于像我这样的人,我并没有弄清楚。 Basically, my code is: 基本上,我的代码是:

(app.jsx): (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>
    )
  }
}

When I run though, I am getting this error: 但是,当我运行时,出现此错误:

在此处输入图片说明

Can anyone assist in this? 有人可以协助吗?

Thanks much. 非常感谢。

Update: I fixed the syntax error as suggested and as I am trying to use this to learn something new in react, I am using a sample project of this project , but now get this as shown in screenshot: 更新:我按照建议修复了语法错误,并且由于我试图使用它来学习React中的新知识,所以我正在使用该项目的示例项目 ,但是现在如截图所示:

在此处输入图片说明

Webpack build errors can be subtle sometimes: Webpack构建错误有时可能很细微:

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>
    )
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM