Skip to content

Commit

Permalink
feat: Check that currentIndex is in indices list
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelastic committed Sep 8, 2015
1 parent b60ed36 commit 494dbe9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions widgets/index-selector/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var React = require('react');

var findIndex = require('lodash/array/findIndex');
var utils = require('../../lib/widgetUtils.js');

function indexSelector({container = null, indices = null}) {
Expand All @@ -12,6 +13,13 @@ function indexSelector({container = null, indices = null}) {
}

return {
init: function(state, helper) {
var currentIndex = helper.getIndex();
var isIndexInList = findIndex(indices, {'name': currentIndex}) !== -1;
if (!isIndexInList) {
throw new Error('[stats]: Index ' + currentIndex + ' not present in `indices`');
}
},
render: function(results, state, helper) {
React.render(
<IndexSelector
Expand Down

0 comments on commit 494dbe9

Please sign in to comment.