Skip to content

Commit

Permalink
Stop node removal when node count reaches 1 (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushpinder107 authored and danielcaldas committed Jan 17, 2020
1 parent a98258a commit 4ecf18c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sandbox/Sandbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class Sandbox extends React.Component {
* Remove a node.
*/
onClickRemoveNode = () => {
if (this.state.data.nodes && this.state.data.nodes.length) {
if (this.state.data.nodes && this.state.data.nodes.length > 1) {
const id = this.state.data.nodes[0].id;

this.state.data.nodes.splice(0, 1);
Expand All @@ -172,7 +172,7 @@ export default class Sandbox extends React.Component {

this.setState({ data });
} else {
toast("No more nodes to remove!");
toast("Need to have at least one node!");
}
};

Expand Down

0 comments on commit 4ecf18c

Please sign in to comment.