Update example code to use React Class syntax (#16)

* Update to use React Class syntax

This is the recommended syntax to use now, and as such will be more familiar to beginners. :)

* Converted old requires to import statements.
This commit is contained in:
Ruben Martinez Jr
2017-06-12 03:02:20 -07:00
committed by Jason Salzman
parent 66d602884b
commit 17efec9b08
+7 -11
View File
@@ -20,15 +20,12 @@ npm install react-add-to-calendar --save
Youll need to install React and Moment separately since they are not included in the package. Below is a simple example on how to use the Add to Calendar button in a React view.
```js
var React = require('react');
var createReactClass = require('create-react-class');
var AddToCalendar = require('react-add-to-calendar');
import React from 'react';
import AddToCalendar from 'react-add-to-calendar';
var Example = createReactClass({
displayName: 'Example',
getInitialState: function() {
return {
class Example extends React.Component {
static displayName = 'Example';
state = {
event: {
title: 'Sample Event',
description: 'This is the sample event provided as an example only',
@@ -37,12 +34,11 @@ var Example = createReactClass({
endTime: '2016-09-16T21:45:00-04:00'
}
};
},
render: function() {
render() {
return <AddToCalendar event={this.state.event}/>;
};
}
});
```
## Configuration