Skip to content

Commit

Permalink
fix: avoid React warning about required proptype (#311)
Browse files Browse the repository at this point in the history
"Warning: Failed prop type: The prop `items[0].name` is
marked as required in `AxisSetup`, but its value is `undefined`.
    in AxisSetup (created by WithStyles(AxisSetup))"

was sometimes popping up and it turned out sometimes there is no name
available in the metadata for the item object.
Changed the code to initialize the name to empty string when not
available instead of passing undefined.
  • Loading branch information
edoardo committed Aug 21, 2019
1 parent e5e0a7b commit 5dda862
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/app/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export {
};

export const sGetAxisSetupItems = state =>
fromUi.sGetAxisSetup(state).map(obj => ({
...obj,
name: (fromMetadata.sGetMetadata(state)[obj.id] || {}).name,
}));
fromUi.sGetAxisSetup(state).map(obj => {
const metadata = fromMetadata.sGetMetadata(state)[obj.id];

return {
...obj,
name: metadata ? metadata.name : '',
};
});

0 comments on commit 5dda862

Please sign in to comment.