Skip to content

Commit

Permalink
fixed Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Narendra Sisodiya committed Apr 28, 2019
1 parent f6ceeaa commit f6a22a2
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 22 deletions.
4 changes: 2 additions & 2 deletions dist/index.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.es.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-scripts": "^1.1.4",
"react-json-viewer": "file:.."
"react-gist": "^1.2.1",
"react-json-viewer": "file:..",
"react-scripts": "^1.1.4"
},
"scripts": {
"start": "react-scripts start",
Expand Down
62 changes: 50 additions & 12 deletions example/src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
import React, { Component } from 'react';

import Gist from 'react-gist';
import JSONViewer from 'react-json-viewer';

var testData = {
name: 'Narendra',
age: 32,
place: {
name: 'Delhi',
pin: '110017',
},
likes: ['Apple', 'Banana', 'Mango'],
test: {
userData: undefined,
loginData: null,
},
todos: [
{
task: 'Write Book',
done: false,
},
{
task: 'Learn React',
done: true,
},
{
task: 'Buy Mobile',
done: false,
},
],
dateWiseData: {
'2016-02-14': {
availableRooms: 10,
soldRooms: 20,
},
'2016-02-15': {
availableRooms: 15,
soldRooms: 15,
},
'2016-02-16': {
availableRooms: 5,
soldRooms: 25,
},
'2016-02-17': {
availableRooms: 0,
soldRooms: 30,
},
},
};
export default class App extends Component {
render() {
return (
<div>
<JSONViewer
json={[
{
task: 'Learn React',
done: true,
},
{
task: 'Write Book',
done: false,
},
]}
/>
<h1>React JSON Viewer Demo</h1>
<JSONViewer json={testData} />
<p>Following Test JSON Data is rendered above into a Tabular Format using react-json-viewer</p>
<Gist id="f699b5555245f69a1ce53b05545e6e70" />
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ export default class JSONViewer extends Component {
}

arrayToTable(obj) {
if (getType(obj) === 'Array' && obj.length === ZERO) {
if (getType(obj) === 'Array' && obj.length === 0) {
return '[ ]';
} else {
return (
<table {...this.props.tableProps}>
<tbody>
{loopObject(obj, (v, key) => {
return (
<tr {...this.props.trProps}>
<tr key={key} {...this.props.trProps}>
<td {...this.props.tdProps} style={this.constructor.styles.td}>{`${key}`}</td>
{this.renderTd(v, key)}
</tr>
Expand Down

0 comments on commit f6a22a2

Please sign in to comment.