Skip to content
This repository has been archived by the owner on Oct 18, 2019. It is now read-only.

Commit

Permalink
Code review - handle children is not provided(null)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhsine committed Jan 30, 2018
1 parent 059ddb4 commit 1b63ec1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions side-bar/components/side-bar-hoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,16 @@ export default function decorateSideBar(DecoratedComponent) {

render() {
const { anchors, children, ...passThroughProps } = this.props
let modules = children
if (children && !Array.isArray(children)) {

let modules
if (!children) {
modules = []
} else if (Array.isArray(children)) {
modules = children
} else {
modules = [children]
}

const webSiteContent = modules.map((module, index) => {
const moduleID = _.get(anchors, [index, 'id'], `side_bar_module_${index}`)
let order
Expand All @@ -180,7 +186,7 @@ export default function decorateSideBar(DecoratedComponent) {
onEnter={(props) => { this.handleOnEnter(moduleID, props) }}
fireOnRapidScroll
topOffset="4%"
bottomOffset={(index + 1) === modules.length ? '50%' : '95%'}
bottomOffset={order === lastSection ? '50%' : '95%'}
scrollableAncestor="window"
>
<div
Expand All @@ -191,12 +197,10 @@ export default function decorateSideBar(DecoratedComponent) {
</div>
</Waypoint>
)
},
)
})

return (
<DecoratedComponent
ref={(node) => { this.anchorsNode = node }}
anchors={anchors}
handleClickAnchor={this.handleClickAnchor}
currentAnchorId={this.state.currentSection}
Expand Down

0 comments on commit 1b63ec1

Please sign in to comment.