I'm sorry if it's a duplication of any question, however, I can't find a solution to my problem.
I have a selector that getting a big object with a big nesting. And I need to return some value from it. How can I check is fields exist to prevent crashing?
export const getSingleValue = createSelector(
getEntities,
(entities) => entities
.map(item => {
// need to check is field and oneMoreField, etc. exist
return item.field.oneMoreField.andMoreField.andHereIs.value || null;
})
);
The plan B - wrap returning to try-catch
but I think it's not a good option.