Skip to content

Commit 480627e

Browse files
committed
Validate children before spreading them to flatNodes
1 parent 69eead9 commit 480627e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# react-checkbox-tree
1+
# @r365/react-checkbox-tree
22

33
[![npm](https://img.shields.io/npm/v/react-checkbox-tree.svg?style=flat-square)](https://www.npmjs.com/package/react-checkbox-tree)
44
[![Build Status](https://img.shields.io/travis/jakezatecky/react-checkbox-tree/master.svg?style=flat-square)](https://travis-ci.org/jakezatecky/react-checkbox-tree)
@@ -18,13 +18,13 @@
1818
Install the library using your favorite dependency manager:
1919

2020
```
21-
yarn add react-checkbox-tree
21+
yarn add @r365/react-checkbox-tree
2222
```
2323

2424
Using npm:
2525

2626
```
27-
npm install react-checkbox-tree --save
27+
npm install @r365/react-checkbox-tree --save
2828
```
2929

3030
> **Note** – This library makes use of [Font Awesome](http://fontawesome.io/) styles and expects them to be loaded in the browser.
@@ -34,14 +34,14 @@ npm install react-checkbox-tree --save
3434

3535
For your convenience, the library's styles can be consumed utilizing one of the following files:
3636

37-
* `node_modules/react-checkbox-tree/lib/react-checkbox-tree.css`
38-
* `node_modules/react-checkbox-tree/src/less/react-checkbox-tree.less`
39-
* `node_modules/react-checkbox-tree/src/scss/react-checkbox-tree.scss`
37+
* `node_modules/@r365/react-checkbox-tree/lib/react-checkbox-tree.css`
38+
* `node_modules/@r365/react-checkbox-tree/src/less/react-checkbox-tree.less`
39+
* `node_modules/@r365/react-checkbox-tree/src/scss/react-checkbox-tree.scss`
4040

4141
Either include one of these files in your stylesheets or utilize a CSS loader:
4242

4343
``` javascript
44-
import 'react-checkbox-tree/lib/react-checkbox-tree.css';
44+
import '@r365/react-checkbox-tree/lib/react-checkbox-tree.css';
4545
```
4646

4747

@@ -51,7 +51,7 @@ A quick usage example is included below. Note that the react-checkbox-tree compo
5151

5252
``` jsx
5353
import React from 'react';
54-
import CheckboxTree from 'react-checkbox-tree';
54+
import CheckboxTree from '@r365/react-checkbox-tree';
5555

5656
const nodes = [{
5757
value: 'mars',
@@ -86,7 +86,7 @@ All node objects **must** have a unique `value`. This value is serialized into t
8686

8787
#### Changing the Default Icons
8888

89-
By default, **react-checkbox-tree** uses Font Awesome for the various icons that appear in the tree. To change the defaults, simply pass in the `icons` property and override the defaults. Note that you can override as many or as little icons as you like:
89+
By default, **@r365/react-checkbox-tree** uses Font Awesome for the various icons that appear in the tree. To change the defaults, simply pass in the `icons` property and override the defaults. Note that you can override as many or as little icons as you like:
9090

9191
``` jsx
9292
<CheckboxTree

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@r365/react-checkbox-tree",
3-
"version": "2.0.5",
3+
"version": "2.0.6",
44
"description": "A simple and elegant checkbox tree for React.",
55
"author": "Jake Zatecky",
66
"license": "MIT",

src/js/NodeModel.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class NodeModel {
4949
index,
5050
};
5151
} else {
52-
this.flatNodes[node.value].children = [...this.flatNodes[node.value].children, ...node.children]
52+
const children = this.flatNodes[node.value].children || [];
53+
this.flatNodes[node.value].children = [...children, ...node.children]
5354
}
5455
this.flattenNodes(node.children, node, depth + 1);
5556
});

0 commit comments

Comments
 (0)