Skip to content

Commit

Permalink
Merge pull request #3946 from newoga/remove-react-addons-update
Browse files Browse the repository at this point in the history
[Core] Remove react-addons-update dependency
  • Loading branch information
oliviertassinari committed May 13, 2016
2 parents 3329d6b + dd751c2 commit 9d20ad3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"lodash.throttle": "^4.0.1",
"react-addons-create-fragment": "^15.0.1",
"react-addons-transition-group": "^15.0.1",
"react-addons-update": "^15.0.1",
"react-event-listener": "^0.2.1",
"recompose": "^0.17.0",
"simple-assign": "^0.1.0",
Expand Down
10 changes: 6 additions & 4 deletions src/Menu/Menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {Component, PropTypes} from 'react';
import ReactDOM from 'react-dom';
import update from 'react-addons-update';
import shallowEqual from 'recompose/shallowEqual';
import ClickAwayListener from '../internal/ClickAwayListener';
import autoPrefix from '../utils/autoPrefix';
Expand Down Expand Up @@ -412,9 +411,12 @@ class Menu extends Component {

if (multiple) {
const itemIndex = menuValue.indexOf(itemValue);
const newMenuValue = itemIndex === -1 ?
update(menuValue, {$push: [itemValue]}) :
update(menuValue, {$splice: [[itemIndex, 1]]});
const [...newMenuValue] = menuValue;
if (itemIndex === -1) {
newMenuValue.push(itemValue);
} else {
newMenuValue.splice(itemIndex, 1);
}

valueLink.requestChange(event, newMenuValue);
} else if (!multiple && itemValue !== menuValue) {
Expand Down
18 changes: 5 additions & 13 deletions src/internal/TouchRipple.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@ import ReactDOM from 'react-dom';
import ReactTransitionGroup from 'react-addons-transition-group';
import Dom from '../utils/dom';
import CircleRipple from './CircleRipple';
import update from 'react-addons-update';

function push(array, obj) {
const newObj = Array.isArray(obj) ? obj : [obj];
return update(array, {$push: newObj});
}

function shift(array) {
// Remove the first element in the array using React immutability helpers
return update(array, {$splice: [[0, 1]]});
}
// Remove the first element of the array
const shift = ([, ...newArray]) => newArray;

class TouchRipple extends Component {
static propTypes = {
Expand Down Expand Up @@ -61,15 +53,15 @@ class TouchRipple extends Component {
let ripples = this.state.ripples;

// Add a ripple to the ripples array
ripples = push(ripples, (
ripples = [...ripples, (
<CircleRipple
key={this.state.nextKey}
style={!this.props.centerRipple ? this.getRippleStyle(event) : {}}
color={this.props.color || theme.color}
opacity={this.props.opacity}
touchGenerated={isRippleTouchGenerated}
/>
));
)];

this.ignoreNextMouseDown = isRippleTouchGenerated;
this.setState({
Expand Down Expand Up @@ -140,7 +132,7 @@ class TouchRipple extends Component {
const abortedRipple = React.cloneElement(ripple, {aborted: true});
// Remove the old ripple and replace it with the new updated one
currentRipples = shift(currentRipples);
currentRipples = push(currentRipples, abortedRipple);
currentRipples = [...currentRipples, abortedRipple];
this.setState({ripples: currentRipples}, () => {
// Call end after we've set the ripple to abort otherwise the setState
// in end() merges with this and the ripple abort fails
Expand Down
10 changes: 4 additions & 6 deletions src/styles/themeManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import update from 'react-addons-update';
import merge from 'lodash.merge';
import getMuiTheme from '../styles/getMuiTheme';
import warning from 'warning';
Expand All @@ -7,23 +6,22 @@ export default
{
getMuiTheme(baseTheme, muiTheme) {
warning(false, 'ThemeManager is deprecated. please import getMuiTheme' +
' directly from "material-ui/getMuiTheme"');
' directly from "material-ui/styles/getMuiTheme"');
return getMuiTheme(baseTheme, muiTheme);
},
modifyRawThemeSpacing(muiTheme, spacing) {
warning(false, 'modifyRawThemeSpacing is deprecated. please use getMuiTheme ' +
' to modify your theme directly. http://www.material-ui.com/#/customization/themes');
return getMuiTheme(update(muiTheme.baseTheme, {spacing: {$set: spacing}}));
return getMuiTheme(merge({}, muiTheme.baseTheme, {spacing}));
},
modifyRawThemePalette(muiTheme, palette) {
warning(false, 'modifyRawThemePalette is deprecated. please use getMuiTheme ' +
' to modify your theme directly. http://www.material-ui.com/#/customization/themes');
const newPalette = merge(muiTheme.baseTheme.palette, palette);
return getMuiTheme(update(muiTheme.baseTheme, {palette: {$set: newPalette}}));
return getMuiTheme(merge({}, muiTheme.baseTheme, {baseTheme: {palette}}));
},
modifyRawThemeFontFamily(muiTheme, fontFamily) {
warning(false, 'modifyRawThemeFontFamily is deprecated. please use getMuiTheme ' +
' to modify your theme directly. http://www.material-ui.com/#/customization/themes');
return getMuiTheme(update(muiTheme.baseTheme, {fontFamily: {$set: fontFamily}}));
return getMuiTheme(merge({}, muiTheme.baseTheme, {fontFamily}));
},
};

0 comments on commit 9d20ad3

Please sign in to comment.