From 0443644ccda522f71a75b22062512337f893866e Mon Sep 17 00:00:00 2001 From: Gary Menzel Date: Mon, 27 Nov 2017 09:50:36 +1100 Subject: [PATCH] Fixes #643 Still requires some basic sanity test to ensure ReactTable does not have any fundamental coding errors. Modified some of the /docs code to help with manual testing. --- docs/src/App.js | 22 ++---- docs/src/examples/expander/index.js | 105 +++++++++++++++------------- docs/src/stories/test.js | 31 ++++++++ src/utils.js | 22 +++--- 4 files changed, 103 insertions(+), 77 deletions(-) create mode 100644 docs/src/stories/test.js diff --git a/docs/src/App.js b/docs/src/App.js index 3efcc39..dcddce8 100644 --- a/docs/src/App.js +++ b/docs/src/App.js @@ -9,31 +9,17 @@ import '../../react-table.css' import Readme from './stories/Readme.js' import HOCReadme from './stories/HOCReadme.js' +// import Test from './stories/test.js' // import Tester from './examples/expander'; -// import { TreeTable, SelectTable, SelectTreeTable } from './examples/index' -// -// const exampleStories = [ -// // examples -// { name: 'TreeTable', component: TreeTable }, -// { name: 'SelectTable', component: SelectTable }, -// { name: 'SelectTreeTable', component: SelectTreeTable }, -// ] - -import { TreeTable, CheckboxTable } from './examples/index' - -const exampleStories = [ - // examples - { name: 'TreeTable', component: TreeTable }, - { name: 'CheckboxTable', component: CheckboxTable }, -]; - const stories = [ { name: 'Readme', component: Readme }, { name: 'HOC Readme', component: HOCReadme }, - // { name: 'Tester', component: Tester }, + // ...exampleStories, + + // { name: 'Tester', component: Test }, { name: 'Simple Table', component: CodeSandbox('X6npLXPRW') }, { name: 'Cell Renderers & Custom Components', diff --git a/docs/src/examples/expander/index.js b/docs/src/examples/expander/index.js index 31c08eb..5403e25 100644 --- a/docs/src/examples/expander/index.js +++ b/docs/src/examples/expander/index.js @@ -1,54 +1,61 @@ -/* eslint-disable */ -import React from 'react'; +import React from 'react' -import ReactTable from '../../../../lib/index' -import '../../../../react-table.css' - -const data = [ - {one:"1.1",two:"1.2"}, - {one:"2.1",two:"2.2"}, - {one:"3.1",two:"3.2"}, - {one:"4.1",two:"4.2"}, -] - -const columns = [ - {accessor:'one', Header: 'One'}, - {accessor:'two', Header: 'Two'}, -] - -class ExpanderComponent extends React.Component { - render() - { - return ( -
- • -
- ) +export default class ComponentTest extends React.component { + render () { + return
Bozo
} } -class SubComponent extends React.Component { - render() - { - return
Nothing
- } -} - -export default class ComponentTest extends React.Component { - render() - { - const rtProps = { - data, - columns, - ExpanderComponent: (props)=>, - SubComponent: (props)=>, - multiSort: false, - } - return ( - - ) - } -} +// import ReactTable from '../../../../lib/index' +// import '../../../../react-table.css' +// +// console.log('ReactTable:',ReactTable) +// +// const data = [ +// {one:"1.1",two:"1.2"}, +// {one:"2.1",two:"2.2"}, +// {one:"3.1",two:"3.2"}, +// {one:"4.1",two:"4.2"}, +// ] +// +// const columns = [ +// {accessor:'one', Header: 'One'}, +// {accessor:'two', Header: 'Two'}, +// ] +// +// class ExpanderComponent extends React.Component { +// render() +// { +// return ( +//
+// • +//
+// ) +// } +// } +// +// class SubComponent extends React.Component { +// render() +// { +// return
Nothing
+// } +// } +// +// export default class ComponentTest extends React.Component { +// render() +// { +// const rtProps = { +// data, +// columns, +// // ExpanderComponent: (props)=>, +// // SubComponent: (props)=>, +// // multiSort: false, +// } +// return ( +// +// ) +// } +// } diff --git a/docs/src/stories/test.js b/docs/src/stories/test.js new file mode 100644 index 0000000..5e98633 --- /dev/null +++ b/docs/src/stories/test.js @@ -0,0 +1,31 @@ + +import React from 'react' + +import ReactTable from '../../../lib/index' +import '../../../react-table.css' + +const data = [ + { one: '1.1', two: '1.2' }, + { one: '2.1', two: '2.2' }, + { one: '3.1', two: '3.2' }, + { one: '4.1', two: '4.2' }, +] + +const columns = [ + { accessor: 'one', Header: 'One' }, + { accessor: 'two', Header: 'Two' }, +] + +export default class Story extends React.Component { + render () { + return ( +
+ Test + +
+ ) + } +} diff --git a/src/utils.js b/src/utils.js index 3848f47..6a46465 100644 --- a/src/utils.js +++ b/src/utils.js @@ -188,16 +188,18 @@ function splitProps ({ className, style, ...rest }) { function compactObject (obj) { const newObj = {} - Object.keys(obj).map(key => { - if ( - Object.prototype.hasOwnProperty.call(obj, key) && - obj[key] !== undefined && - typeof obj[key] !== 'undefined' - ) { - newObj[key] = obj[key] - } - return true - }) + if (obj) { + Object.keys(obj).map(key => { + if ( + Object.prototype.hasOwnProperty.call(obj, key) && + obj[key] !== undefined && + typeof obj[key] !== 'undefined' + ) { + newObj[key] = obj[key] + } + return true + }) + } return newObj }