Skip to content

app crashed when current[key] is null #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/components/ProductsContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class ProductsContainer extends Component {
}

componentDidMount() {
if (this.props.products.get('$fetched')) {
return
}
fetchNeeds( ProductsContainer.needs, this.props )
}

Expand Down
1 change: 1 addition & 0 deletions common/constants/Types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Immutable from 'immutable';

// define ProductState shape inside redux state
export const ProductState = Immutable.Record({
$fetched: false,
productsById: Immutable.Map(),
total: '0',
})
Expand Down
5 changes: 4 additions & 1 deletion common/utils/fetchComponentData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export default function fetchComponentData(dispatch, components, params) {
const needs = components.reduce( (prev, current) => {

return Object.keys(current).reduce( (acc, key) => {
return current[key].hasOwnProperty('needs') ? current[key].needs.concat(acc) : acc
if (!!current[key] && current[key].hasOwnProperty('needs')) {
return current[key].needs.concat(acc)
}
return acc
}, prev)

}, []);
Expand Down