Closed szaboako closed 2 years ago
This issue actually had two parts:
the first is some styling was missing from the styles.js, that made the page fall apart (that solved the warning)
cardAction: {
display: 'block',
textAlign: 'initial',
},
the second was due to a thing called "bubbling" that basically means in this case that 1st the inner elements event fires then the outers so we have to stop the second event from happening in order to be able to edit our posts and not be navigated to the details page instead. To solve this I added a handleEdit function instead of the inline one. The event.stopPropagation stops the bubbling.
const handleEdit = (e) => {
setCurrentId(post._id)
e.stopPropagation();
}
<Button style={{color: 'white'}} size="small" onClick={handleEdit}>
<MoreHorizIcon fontSize="medium" />
</Button>
You saved my world, appreciate for your help!
Hello,
In the components/Posts/Post/Post.js file there is a Button embedded into a ButtonBase component that creates a warning and also destroys the Home page where these components are used via the Posts component.
The warning says this: validateDOMNesting(...):
<button>
cannot appear as a descendant of<button>
If I change the ButtonBase to a simple div (it loses a lot of styling) the edit button is still unusable because it registers the parent divs onClick first.
How can I solve this?