From 3ab3a128deaf10300b31102b79458528227baa54 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 14 Apr 2017 17:13:04 +0800 Subject: fix react createClass and PropTypes warning --- examples/format.js | 29 ++++++++++------------------- examples/open.js | 22 ++++++++++------------ examples/value-and-defaultValue.js | 22 ++++++++++------------ 3 files changed, 30 insertions(+), 43 deletions(-) (limited to 'examples') diff --git a/examples/format.js b/examples/format.js index c9a9539..e9a2614 100644 --- a/examples/format.js +++ b/examples/format.js @@ -4,23 +4,14 @@ import ReactDom from 'react-dom'; import moment from 'moment'; import TimePicker from 'rc-time-picker'; -const App = React.createClass({ - render() { - return ( -
- - - - - - - -
- ); - }, -}); - ReactDom.render( - , - document.getElementById('__react-content') -); +
+ + + + + + + +
+, document.getElementById('__react-content')); diff --git a/examples/open.js b/examples/open.js index 100bf35..8e4f5de 100644 --- a/examples/open.js +++ b/examples/open.js @@ -6,20 +6,18 @@ import React from 'react'; import ReactDom from 'react-dom'; import TimePicker from 'rc-time-picker'; -const App = React.createClass({ - getInitialState() { - return { - open: false, - }; - }, - setOpen({ open }) { +class App extends React.Component { + state = { + open: false, + }; + setOpen = ({ open }) => { this.setState({ open }); - }, - toggleOpen() { + } + toggleOpen = () => { this.setState({ open: !this.state.open, }); - }, + } render() { return (
@@ -27,8 +25,8 @@ const App = React.createClass({
); - }, -}); + } +} ReactDom.render( , diff --git a/examples/value-and-defaultValue.js b/examples/value-and-defaultValue.js index 0e1aa14..1e1baf8 100644 --- a/examples/value-and-defaultValue.js +++ b/examples/value-and-defaultValue.js @@ -7,21 +7,19 @@ import ReactDom from 'react-dom'; import moment from 'moment'; import TimePicker from 'rc-time-picker'; -const App = React.createClass({ - getInitialState() { - return { - value: moment(), - }; - }, - handleValueChange(value) { +class App extends React.Component { + state = { + value: moment(), + }; + handleValueChange = (value) => { console.log(value && value.format('HH:mm:ss')); this.setState({ value }); - }, - clear() { + } + clear = () => { this.setState({ value: undefined, }); - }, + } render() { return (
@@ -36,8 +34,8 @@ const App = React.createClass({
); - }, -}); + } +} ReactDom.render( , -- cgit v1.2.3