From 17efec9b08a4cd5c504558e0c81467858ec15a89 Mon Sep 17 00:00:00 2001 From: Ruben Martinez Jr Date: Mon, 12 Jun 2017 03:02:20 -0700 Subject: [PATCH] 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. --- README.md | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7076d6b..b84e8cd 100644 --- a/README.md +++ b/README.md @@ -20,29 +20,25 @@ 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', +class Example extends React.Component { + static displayName = 'Example'; + state = { + event: { + title: 'Sample Event', + description: 'This is the sample event provided as an example only', + location: 'Portland, OR', + startTime: '2016-09-16T20:15:00-04:00', + endTime: '2016-09-16T21:45:00-04:00' + } + }; - getInitialState: function() { - return { - event: { - title: 'Sample Event', - description: 'This is the sample event provided as an example only', - location: 'Portland, OR', - startTime: '2016-09-16T20:15:00-04:00', - endTime: '2016-09-16T21:45:00-04:00' - } - }; - }, - - render: function() { + render() { return ; - } -}); + }; +} ``` ## Configuration @@ -89,4 +85,4 @@ The examples are hosted within the docs folder and are ran in the simple add tha ## License -Copyright (c) 2016-2017 Jason Salzman. Licensed under MIT license, see [LICENSE](LICENSE) for the full license. \ No newline at end of file +Copyright (c) 2016-2017 Jason Salzman. Licensed under MIT license, see [LICENSE](LICENSE) for the full license.