{props.stories.map((story) =>
<div key={story.id}>
{story = story.story}
<SliderItem story={story} />
</div>
)}
The above code throws an error saying:
Uncaught (in promise) Error: Objects are not valid as a React child (found: object with keys
because story
in line number 3 is an object.
I can move that condition directly as <SliderItem story={story.story} />
, but I want to know if there is any way I can assign my calculated value to a variable and use it in JSX?
I want to apply some logic like:
{ let storyObj = story.type === 'story' && story.story ? story.story : story }