question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React components inside code

See original GitHub issue

Why it isn’t possible to do this?


```js

<Component />


It works if you put it outside of the code:
```md
<Component />
```js
var t = false;

Where is exactly the limitation, inside remark AST?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gaurav-nelsoncommented, Jul 18, 2019

It’s possible to do this by providing a custom code component to MDXProvider.

@nicknovitski Thanks for sharing. Is there an example available for such a component?

1reaction
montogeekcommented, Aug 23, 2018

Sorry for the noise, let me try once again: I would like to render a React component inside Markdown backticks (code) “```”, right now it is not possible, it get interpreted as simple strings instead of JSX.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSX In Depth - React
The first part of a JSX tag determines the type of the React element. Capitalized types indicate that the JSX tag is referring...
Read more >
Code Review: Avoid Declaring React Component Inside ...
After the section above, I put one note into my Code Review checklist for React: avoid declaring a component within another component.
Read more >
How to put JS code inside React component - Stack Overflow
Does anyone know how to do it? mycomponent.js import React from "react"; import Navbar from ...
Read more >
React Components - W3Schools
Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML....
Read more >
How to Use JavaScript React Components within TypeScript ...
In code given above, we define a JavaScript React component and make a TypeScript interface from start. Doing this has the great chance...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found