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
+8 -12
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. 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 ```js
var React = require('react'); import React from 'react';
var createReactClass = require('create-react-class'); import AddToCalendar from 'react-add-to-calendar';
var AddToCalendar = require('react-add-to-calendar');
var Example = createReactClass({ class Example extends React.Component {
displayName: 'Example', static displayName = 'Example';
state = {
getInitialState: function() {
return {
event: { event: {
title: 'Sample Event', title: 'Sample Event',
description: 'This is the sample event provided as an example only', 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' endTime: '2016-09-16T21:45:00-04:00'
} }
}; };
},
render: function() { render() {
return <AddToCalendar event={this.state.event}/>; return <AddToCalendar event={this.state.event}/>;
} };
}); }
``` ```
## Configuration ## Configuration