Skip to content

Commit 02a9706

Browse files
committed
Fix issue where numeric node values could trigger PropType warnings
Going back several builds, there were actually warnings to this effect being outputted to the console. Resolves #105.
1 parent f1fbc54 commit 02a9706

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/js/CheckboxTree.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import React from 'react';
55
import nanoid from 'nanoid';
66

77
import TreeNode from './TreeNode';
8+
import listShape from './listShape';
89
import nodeShape from './nodeShape';
910

1011
class CheckboxTree extends React.Component {
1112
static propTypes = {
1213
nodes: PropTypes.arrayOf(nodeShape).isRequired,
1314

14-
checked: PropTypes.arrayOf(PropTypes.string),
15+
checked: listShape,
1516
disabled: PropTypes.bool,
1617
expandDisabled: PropTypes.bool,
1718
expandOnClick: PropTypes.bool,
18-
expanded: PropTypes.arrayOf(PropTypes.string),
19+
expanded: listShape,
1920
name: PropTypes.string,
2021
nameAsArray: PropTypes.bool,
2122
nativeCheckboxes: PropTypes.bool,

src/js/TreeNode.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ class TreeNode extends React.Component {
1515
optimisticToggle: PropTypes.bool.isRequired,
1616
showNodeIcon: PropTypes.bool.isRequired,
1717
treeId: PropTypes.string.isRequired,
18-
value: PropTypes.string.isRequired,
18+
value: PropTypes.oneOfType([
19+
PropTypes.string,
20+
PropTypes.number,
21+
]).isRequired,
1922
onCheck: PropTypes.func.isRequired,
2023
onExpand: PropTypes.func.isRequired,
2124

src/js/listShape.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import PropTypes from 'prop-types';
2+
3+
const listShape = PropTypes.oneOfType([
4+
PropTypes.arrayOf(PropTypes.string),
5+
PropTypes.arrayOf(PropTypes.number),
6+
]);
7+
8+
export default listShape;

0 commit comments

Comments
 (0)