Skip to content

Commit 17efec9

Browse files
rubencodesjasonsalzman
authored andcommitted
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.
1 parent 66d6028 commit 17efec9

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

README.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,25 @@ npm install react-add-to-calendar --save
2020
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.
2121

2222
```js
23-
var React = require('react');
24-
var createReactClass = require('create-react-class');
25-
var AddToCalendar = require('react-add-to-calendar');
26-
27-
var Example = createReactClass({
28-
displayName: 'Example',
29-
30-
getInitialState: function() {
31-
return {
32-
event: {
33-
title: 'Sample Event',
34-
description: 'This is the sample event provided as an example only',
35-
location: 'Portland, OR',
36-
startTime: '2016-09-16T20:15:00-04:00',
37-
endTime: '2016-09-16T21:45:00-04:00'
38-
}
39-
};
40-
},
41-
42-
render: function() {
23+
import React from 'react';
24+
import AddToCalendar from 'react-add-to-calendar';
25+
26+
class Example extends React.Component {
27+
static displayName = 'Example';
28+
state = {
29+
event: {
30+
title: 'Sample Event',
31+
description: 'This is the sample event provided as an example only',
32+
location: 'Portland, OR',
33+
startTime: '2016-09-16T20:15:00-04:00',
34+
endTime: '2016-09-16T21:45:00-04:00'
35+
}
36+
};
37+
38+
render() {
4339
return <AddToCalendar event={this.state.event}/>;
44-
}
45-
});
40+
};
41+
}
4642
```
4743

4844
## Configuration
@@ -89,4 +85,4 @@ The examples are hosted within the docs folder and are ran in the simple add tha
8985

9086
## License
9187

92-
Copyright (c) 2016-2017 Jason Salzman. Licensed under MIT license, see [LICENSE](LICENSE) for the full license.
88+
Copyright (c) 2016-2017 Jason Salzman. Licensed under MIT license, see [LICENSE](LICENSE) for the full license.

0 commit comments

Comments
 (0)