mirror of
https://github.com/encounter/react-add-to-calendar.git
synced 2026-07-10 21:18:44 -07:00
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:
committed by
Jason Salzman
parent
66d602884b
commit
17efec9b08
@@ -20,15 +20,12 @@ npm install react-add-to-calendar --save
|
||||
You’ll 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
|
||||
|
||||
Reference in New Issue
Block a user