remarkjs / react-markdown

Markdown component for React
https://remarkjs.github.io/react-markdown/
MIT License
13.26k stars 876 forks source link

Attach onClick attribute to the elements #856

Closed MuthuChess closed 2 months ago

MuthuChess commented 2 months ago

Initial checklist

Problem

I want to understand if it is allowed to attach an onClick event when mapping tag names to components. When the Markdown renders, the onclick attribute is not seen in the DOM.

<Markdown children={"some markdown content with a tag"} components={{ a: (props) => <button onClick={() => console.log('alert clicked')}> {props.children} }} />

Solution

Would like to know if there is a way to call onClick attribute

Alternatives

Would like to know if there is a way to have a method called on click of an 'a' tag

wooorm commented 2 months ago

Your question has to do with React. But you post an issue here on react-markdown. Try the same out, without react-markdown, and see the same happening.

github-actions[bot] commented 2 months ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.