previewRender should allow a react component as return value
See original GitHub issueHello,
I tried to integrate this in a project where we use react-markdown
and would like to use the ReactMarkdown
Component in previewRender
to keep preview and live rendering consistent - sadly previewRender
expects a string
as far as i can see. So sth like:
<SimpleMDE
value={this.state.text}
onChange={this.setText}
options={{
previewRender (text) {
return <ReactMarkdown
source={text}
renderers={{
CodeBlock: CodeRenderer,
Code: CodeRenderer
}}
/>
}
}}
/>
is currently not possible.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Components and Props - React
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to...
Read more >Should a component's render method have return type React ...
createElement and is narrow in scope whereas React.ReactNode is more broad and covers all possible values that a Component could return.
Read more >Return a Variable in the Render Function in React | Pluralsight
Thus, the JSX elements can also get returned to the variable, and that variable can be used for rendering. For an example demonstration,...
Read more >React Class Components - W3Schools
When creating a React component, the component's name must start with an upper ... The component also requires a render() method, this method...
Read more >How to use Props in React - Robin Wieruch
A bit later you will split out your first React function component: import * as React from 'react';. const App = () =>...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@btzr-io Just tested it. WORKS PERFECTLY 😄
Giving me perfect
LOL
in the preview 😄@ningappa use code above to solve your issue 😃
Will update Readme.md now.
@btzr-io 😄 Should work tho.
@ningappa Make JSX in the preview seems impossible for me. We just expose here an option object here that basically create a new instance of SimpleMDE that we make controllable using React, we are unable to intervene into the previewRenderer here to make it JSX controllable. I will dig into the docs of SimpleMDE now but I’m not sure whether it’s possible. A workaround of @btzr-io looks good, not sure about the performance of such tho, and whether this function works on non-Node.js environment but web 😃