mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
feat(v2): allow adding components to react-live scope (#2826)
* feat(v2): add components to react-live scope (#2807) * fix admonition issue + improve react-live scope doc * fix again admonition :( * remove forwarding of mdx components to react-live scope (for now) * remove useless dep
This commit is contained in:
parent
5c6670b94e
commit
953abd8154
5 changed files with 102 additions and 1 deletions
|
@ -9,6 +9,7 @@ import React from 'react';
|
|||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||
import usePrismTheme from '@theme/hooks/usePrismTheme';
|
||||
import Playground from '@theme/Playground';
|
||||
import ReactLiveScope from '@theme/ReactLiveScope';
|
||||
import CodeBlock from '@theme-init/CodeBlock';
|
||||
|
||||
const withLiveEditor = (Component) => {
|
||||
|
@ -20,7 +21,7 @@ const withLiveEditor = (Component) => {
|
|||
return (
|
||||
<Playground
|
||||
key={isClient}
|
||||
scope={{...React}}
|
||||
scope={ReactLiveScope}
|
||||
theme={prismTheme}
|
||||
{...props}
|
||||
/>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
// Add react-live imports you need here
|
||||
const ReactLiveScope = {
|
||||
React,
|
||||
...React,
|
||||
};
|
||||
|
||||
export default ReactLiveScope;
|
Loading…
Add table
Add a link
Reference in a new issue