Skip to content

Commit

Permalink
Refactored remove habit to pass the new tests
Browse files Browse the repository at this point in the history
- Currently there is a bug with React Native where the rest operator
does not work when destructuring with an integer key.

- Casting to a string is a temporary fix.

- facebook/react-native#18273
  • Loading branch information
danthomps committed May 5, 2018
1 parent 2b77a61 commit ffe43d1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion containers/habits/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class HabitsContainer extends Container {
addHabit = ({ title, frequency, timesPerDay }) => {
const nextState = {
...this.state.habits,

[habitId]: {
frequency,
status: STATUS.ACTIVE,
Expand All @@ -33,7 +34,7 @@ class HabitsContainer extends Container {
};

removeHabit = id => {
const nextState = this.state.habits.filter(habit => habit.id !== id);
const { [String(id)]: _, ...nextState } = this.state.habits;

this.setState({ habits: nextState });
};
Expand Down

0 comments on commit ffe43d1

Please sign in to comment.