You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
21
21
22
22
```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
+
importReactfrom'react';
24
+
importAddToCalendarfrom'react-add-to-calendar';
25
+
26
+
classExampleextendsReact.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() {
43
39
return<AddToCalendar event={this.state.event}/>;
44
-
}
45
-
});
40
+
};
41
+
}
46
42
```
47
43
48
44
## Configuration
@@ -89,4 +85,4 @@ The examples are hosted within the docs folder and are ran in the simple add tha
89
85
90
86
## License
91
87
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