Skip to content

Commit

Permalink
remove key access in render & adjust code style
Browse files Browse the repository at this point in the history
- https://fb.me/react-special-props, resolves amazeui/amt-starter-kit#7
  • Loading branch information
minwe committed Apr 25, 2016
1 parent 721a2a7 commit 89bc1ff
Show file tree
Hide file tree
Showing 28 changed files with 73 additions and 76 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ ES2015/JSX 编译参见 [Amaze UI Touch Starter Kit](https://github.com/amazeui/

## License

MIT © 2015 AllMobilize Inc.
MIT © 2015 - 2016 AllMobilize Inc.
2 changes: 1 addition & 1 deletion kitchen-sink/pages/ModalExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ModalExample = React.createClass({
if (role === 'confirm') {
console.log('你的选择是:「' + (data ? '确定' : '取消') + '」')
} else if (role === 'prompt') {
console.log('输入的数据是:' + data);
console.log('输入的数据是:', data);
}
},

Expand Down
5 changes: 2 additions & 3 deletions src/js/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ const Accordion = React.createClass({
return React.Children.map(this.props.children, (child, index) => {
let {
eventKey,
key,
} = child.props;
} = child.props;
let props = {
key: key ? key : index,
key: index,
onSelect: this.handleSelect,
};

Expand Down
2 changes: 1 addition & 1 deletion src/js/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Badge = React.createClass({
className,
href,
...props
} = this.props;
} = this.props;
Component = href ? 'a' : Component;

return (
Expand Down
6 changes: 3 additions & 3 deletions src/js/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Button = React.createClass({
component: Component,
children,
...props
} = this.props;
} = this.props;
Component = Component || 'a';

href = href || '#';
Expand All @@ -54,7 +54,7 @@ const Button = React.createClass({
component: Component,
children,
...props,
} = this.props;
} = this.props;
Component = Component || 'button';

return (
Expand All @@ -74,7 +74,7 @@ const Button = React.createClass({
target,
block,
className,
} = this.props;
} = this.props;
let renderType = href || target ? 'renderAnchor' : 'renderButton';

// block button
Expand Down
2 changes: 1 addition & 1 deletion src/js/ButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ButtonGroup = React.createClass({
stacked,
justify,
...props
} = this.props;
} = this.props;

classSet[this.prefixClass('stacked')] = stacked;
classSet[this.prefixClass('justify')] = justify;
Expand Down
4 changes: 2 additions & 2 deletions src/js/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Card = React.createClass({
header,
footer,
...props
} = this.props;
} = this.props;

return (
<div
Expand Down Expand Up @@ -86,7 +86,7 @@ Card.Child = React.createClass({
className,
cover,
...props
} = this.props;
} = this.props;
let classSet = {
className,
[this.prefixClass(role)]: true,
Expand Down
2 changes: 1 addition & 1 deletion src/js/Col.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Col = React.createClass({
component: Component,
className,
...props,
} = this.props;
} = this.props;
let classSet = this.getClassSet();

if (cols) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/Container.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @via https://github.com/JedWatson/react-container
// @see https://github.com/JedWatson/react-container
// @license MIT Copyright (c) 2015 Jed Watson

import React from 'react';
Expand Down Expand Up @@ -112,7 +112,7 @@ let Container = React.createClass({
scrollable,
transition,
...props
} = this.props;
} = this.props;
let classSet = this.getClassSet();

// As view transition container
Expand Down
7 changes: 4 additions & 3 deletions src/js/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const Field = React.createClass({
let {
classPrefix,
...others
} = this.props;
} = this.props;
field = (
<Button
{...props}
Expand All @@ -125,7 +125,8 @@ const Field = React.createClass({
<label
htmlFor={this.props.id}
className={this.prefixClass('container')}
key="label">
key="label"
>
<span className={this.prefixClass('label')}>
{this.props.label}
</span>
Expand All @@ -149,7 +150,7 @@ const Field = React.createClass({
btnBefore,
btnAfter,
...props
} = this.props;
} = this.props;
let renderFiledLabel = (type) => {
return this.props[type] ? (
<span
Expand Down
2 changes: 1 addition & 1 deletion src/js/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Grid = React.createClass({
avg,
align,
...props
} = this.props;
} = this.props;

// .g-collapse
classSet[this.prefixClass('collapse')] = collapse;
Expand Down
2 changes: 1 addition & 1 deletion src/js/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let Group = React.createClass({
footer,
noPadded,
...props,
} = this.props;
} = this.props;
let classSet = this.getClassSet();
classSet[this.prefixClass('no-padded')] = noPadded;

Expand Down
2 changes: 1 addition & 1 deletion src/js/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Icon = React.createClass({
href,
name,
...props
} = this.props;
} = this.props;
Component = href ? 'a' : Component;

// icon-[iconName]
Expand Down
13 changes: 7 additions & 6 deletions src/js/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const List = React.createClass({
className,
inset,
...props
} = this.props;
} = this.props;

classSet[this.prefixClass('inset')] = inset;

Expand Down Expand Up @@ -69,12 +69,13 @@ List.Item = React.createClass({
subTitle,
href,
linkComponent,
} = this.props;
} = this.props;

let itemTitle = title ? (
<h3
key="itemTitle"
className={this.prefixClass('title')}>
className={this.prefixClass('title')}
>
{title}
</h3>
) : null;
Expand Down Expand Up @@ -107,7 +108,7 @@ List.Item = React.createClass({
subTitle,
desc,
children
} = this.props;
} = this.props;
let titleRow = this.renderTitleRow();
let notJustTitle = media || subTitle || desc || children;

Expand All @@ -131,7 +132,7 @@ List.Item = React.createClass({
linkProps,
href,
target,
} = this.props;
} = this.props;

return linkComponent ?
React.createElement(linkComponent, linkProps, children) : (
Expand Down Expand Up @@ -168,7 +169,7 @@ List.Item = React.createClass({
linked,
nested,
...props
} = this.props;
} = this.props;
let itemChildren = [
this.renderAddon('media'),
this.renderMain(),
Expand Down
2 changes: 1 addition & 1 deletion src/js/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Loader = React.createClass({
className,
component: Component,
...props,
} = this.props;
} = this.props;

return (
<Component
Expand Down
10 changes: 5 additions & 5 deletions src/js/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const Modal = React.createClass({
title,
children,
...props
} = this.props;
} = this.props;

return (
<div
Expand Down Expand Up @@ -195,7 +195,7 @@ const Modal = React.createClass({
title,
closeBtn,
role
} = this.props;
} = this.props;
let closeIcon = closeBtn && !role ? (
<Icon
name="close"
Expand Down Expand Up @@ -227,7 +227,7 @@ const Modal = React.createClass({
role,
confirmText,
cancelText,
} = this.props;
} = this.props;

switch (role) {
case 'alert':
Expand Down Expand Up @@ -313,7 +313,7 @@ const Modal = React.createClass({
let {
closed,
isClosing,
} = this.state;
} = this.state;

if (closed) {
return null;
Expand Down Expand Up @@ -346,7 +346,7 @@ const Modal = React.createClass({
modalWidth,
modalHeight,
...props
} = this.props;
} = this.props;
let modal;

classSet[this.prefixClass('out')] = isClosing;
Expand Down
7 changes: 4 additions & 3 deletions src/js/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ const NavBar = React.createClass({
getDefaultProps() {
return {
classPrefix: 'navbar',
onSelect: () => {},
onSelect: () => {
},
};
},

renderTitle() {
let {
titleOnLeft,
title,
} = this.props;
} = this.props;
let titlePosition = this.prefixClass(titleOnLeft ? 'left' : 'center');

return title ? (
Expand Down Expand Up @@ -97,7 +98,7 @@ const NavBar = React.createClass({
title,
className,
...props
} = this.props;
} = this.props;

return (
<header
Expand Down
5 changes: 3 additions & 2 deletions src/js/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const Notification = React.createClass({
return {
classPrefix: 'notification',
closeBtn: true,
onDismiss: () => {},
onDismiss: () => {
},
};
},

Expand All @@ -51,7 +52,7 @@ const Notification = React.createClass({
animated,
visible,
...props
} = this.props;
} = this.props;

classSet[this.prefixClass('animated')] = animated;

Expand Down
4 changes: 2 additions & 2 deletions src/js/OffCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const OffCanvas = React.createClass({
if (e && e.target === this.refs.backdrop) {
let {
onDismiss,
} = this.props;
} = this.props;

onDismiss && onDismiss();
}
Expand All @@ -42,7 +42,7 @@ const OffCanvas = React.createClass({
children,
isClosing,
...props
} = this.props;
} = this.props;

classSet[this.prefixClass('out')] = isClosing;
classSet[this.prefixClass(placement)] = !!placement;
Expand Down
5 changes: 2 additions & 3 deletions src/js/OffCanvasTrigger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {cloneElement} from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import ClassNameMixin from './mixins/ClassNameMixin';
import OverlayMixin from './mixins/OverlayMixin';
import CSSCore from './utils/CSSCore';
Expand Down Expand Up @@ -110,7 +109,7 @@ const OffCanvasTrigger = React.createClass({
getPageContainer() {
let {
pageContainer
} = this.props;
} = this.props;

return typeof pageContainer === 'string' ?
document.querySelector(pageContainer) :
Expand Down Expand Up @@ -142,7 +141,7 @@ const OffCanvasTrigger = React.createClass({
let offCanvas = this.props.offCanvas;
let {
isClosing,
} = this.state;
} = this.state;

if (isClosing) {
let node = this.getOverlayDOMNode();
Expand Down
7 changes: 3 additions & 4 deletions src/js/Popover.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import ClassNameMixin from './mixins/ClassNameMixin';
import BackdropMixin from './mixins/BackdropMixin';
Expand Down Expand Up @@ -28,7 +27,7 @@ const Popover = React.createClass({
if (e && e.target === this.refs.backdrop) {
let {
onDismiss,
} = this.props;
} = this.props;

onDismiss && onDismiss();
}
Expand All @@ -47,7 +46,7 @@ const Popover = React.createClass({
isClosing,
placement,
...props
} = this.props;
} = this.props;
let style = {
left: positionLeft,
top: positionTop,
Expand All @@ -60,7 +59,7 @@ const Popover = React.createClass({
classSet[this.prefixClass('out')] = isClosing;
classSet[this.prefixClass(placement)] = placement;

let popover= (
let popover = (
<div
{...props}
style={style}
Expand Down
Loading

0 comments on commit 89bc1ff

Please sign in to comment.