improve demo es6 class code style

This commit is contained in:
afc163 2017-02-20 21:47:57 +08:00
parent 2da59c3679
commit f2d12306bd
7 changed files with 18 additions and 38 deletions

View File

@ -37,11 +37,8 @@ const columns = [{
}]; }];
class Page extends React.Component { class Page extends React.Component {
constructor() { state = {
super(); visible: false,
this.state = {
visible: false,
};
} }
showModal = () => { showModal = () => {
this.setState({ visible: true }); this.setState({ visible: true });

View File

@ -17,13 +17,11 @@ Wrap your app with `LocaleProvider`, and apply the corresponding language packag
import { Pagination, LocaleProvider } from 'antd'; import { Pagination, LocaleProvider } from 'antd';
import enUS from 'antd/lib/locale-provider/en_US'; import enUS from 'antd/lib/locale-provider/en_US';
function App() { const App = () = >(
return ( <div>
<div> <Pagination defaultCurrent={1} total={50} showSizeChanger />
<Pagination defaultCurrent={1} total={50} showSizeChanger /> </div>
</div> };
);
}
ReactDOM.render( ReactDOM.render(
<LocaleProvider locale={enUS}> <LocaleProvider locale={enUS}>

View File

@ -19,12 +19,9 @@ import { Mention } from 'antd';
const users = ['afc163', 'benjycui', 'yiminghe', 'jljsj33', 'dqaria', 'RaoHai']; const users = ['afc163', 'benjycui', 'yiminghe', 'jljsj33', 'dqaria', 'RaoHai'];
class AsyncMention extends React.Component { class AsyncMention extends React.Component {
constructor() { state = {
super(); suggestions: [],
this.state = { loading: false,
suggestions: [],
loading: false,
};
} }
fetchSuggestions(value, callback) { fetchSuggestions(value, callback) {
setTimeout(() => { setTimeout(() => {

View File

@ -27,11 +27,8 @@ const webFrameworks = [
]; ];
class CustomNavMention extends React.Component { class CustomNavMention extends React.Component {
constructor() { state = {
super(); suggestions: [],
this.state = {
suggestions: [],
};
} }
onSearchChange = (value) => { onSearchChange = (value) => {
const searchValue = value.toLowerCase(); const searchValue = value.toLowerCase();

View File

@ -18,11 +18,8 @@ import { Mention } from 'antd';
const { toEditorState } = Mention; const { toEditorState } = Mention;
class App extends React.Component { class App extends React.Component {
constructor() { state = {
super(); value: toEditorState('@afc163'),
this.state = {
value: toEditorState('@afc163'),
};
} }
handleChange = (editorState) => { handleChange = (editorState) => {
this.setState({ this.setState({

View File

@ -19,11 +19,8 @@ const { toEditorState, getMentions } = Mention;
const FormItem = Form.Item; const FormItem = Form.Item;
class App extends React.Component { class App extends React.Component {
constructor() { state = {
super(); initValue: toEditorState('@afc163'),
this.state = {
initValue: toEditorState('@afc163'),
};
} }
handleReset = (e) => { handleReset = (e) => {
e.preventDefault(); e.preventDefault();

View File

@ -32,11 +32,8 @@ function onSelect(suggestion, data) {
} }
class CustomNavMention extends React.Component { class CustomNavMention extends React.Component {
constructor() { state = {
super(); suggestions: [],
this.state = {
suggestions: [],
};
} }
onSearchChange = (value) => { onSearchChange = (value) => {
const searchValue = value.toLowerCase(); const searchValue = value.toLowerCase();