+
+```jsx live
+import ButtonExample from './ButtonExample';
+
+export default function MyPlayground(props) {
+ return (
+
+ alert('hey!')}>Click me
+
+ );
+}
+```
+
+
+
## Using JSX markup in code blocks {#using-jsx-markup}
Code block in Markdown always preserves its content as plain text, meaning you can't do something like:
diff --git a/website/src/theme/ReactLiveScope/index.ts b/website/src/theme/ReactLiveScope/index.ts
index cfb648377348d..de7692de53715 100644
--- a/website/src/theme/ReactLiveScope/index.ts
+++ b/website/src/theme/ReactLiveScope/index.ts
@@ -6,13 +6,17 @@
*/
import React from 'react';
+import {createRequire} from '@theme-original/CodeBlock';
import {ButtonExample} from './components';
-// Add react-live imports you need here
+// Add globals you need here
const ReactLiveScope = {
React,
...React,
ButtonExample,
+ require: createRequire({
+ './ButtonExample': ButtonExample,
+ }),
};
export default ReactLiveScope;
diff --git a/yarn.lock b/yarn.lock
index 879ca25872f94..8afcc8a335afc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -15363,13 +15363,13 @@ react-lifecycles-compat@^3.0.4:
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
-react-live-runner@^1.0.0-rc.0:
- version "1.0.0-rc.0"
- resolved "https://registry.yarnpkg.com/react-live-runner/-/react-live-runner-1.0.0-rc.0.tgz#118c9d51ef8f623e348f37d3136d0f33606788be"
- integrity sha512-Dwv8zukc+LeCYRCX+ylKLYaKsE/96yzXXfL8EiIZ2D0hUV6J1CBFLEj9KpszVf3vCelOxFM6c47ijC6OVfM3kQ==
+react-live-runner@^1.0.0-rc.1:
+ version "1.0.0-rc.1"
+ resolved "https://registry.yarnpkg.com/react-live-runner/-/react-live-runner-1.0.0-rc.1.tgz#e936c108c059168f8e9c2902d0bc025711e4cf6d"
+ integrity sha512-F6kumGzdC9wuapj1xry4PG7afpmLM5bHh4OxCwbtmO1peSsd4NdEhK/9Y3IHpHjpQytyD4j2bJ7+AoqGB3VzbQ==
dependencies:
prism-react-renderer "^1.2.1"
- react-runner "^1.0.0-rc.0"
+ react-runner "^1.0.0-rc.1"
react-simple-code-editor "^0.11.0"
react-loadable-ssr-addon-v5-slorber@^1.0.1:
@@ -15432,10 +15432,10 @@ react-router@5.2.1, react-router@^5.2.0:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
-react-runner@^1.0.0-rc.0:
- version "1.0.0-rc.0"
- resolved "https://registry.yarnpkg.com/react-runner/-/react-runner-1.0.0-rc.0.tgz#c56e198c0609529daddb2470c1f32141d3dabf8d"
- integrity sha512-GX9ngsKasqmKqXWcmsUzYDmPtJdU5vWPhJr6WLJoxnyjJdK+NU9tkJ+QMjsfrLqGbTZK6DnYXRM1o62DAncCwA==
+react-runner@^1.0.0-rc.1:
+ version "1.0.0-rc.1"
+ resolved "https://registry.yarnpkg.com/react-runner/-/react-runner-1.0.0-rc.1.tgz#500c8c459ee9c18ead8b1a0e1d2928f1d83db31d"
+ integrity sha512-+oPTr2h6CYqAsxaDmaMa2WxkUlA6zVVlNt+odem7jYUFQB2+awBrDUBdFByMCkjguPRJatg9mLtzOBpqorWBlQ==
dependencies:
sucrase "^3.10.1"