@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
52 lines (47 loc) • 1.26 kB
JavaScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import { useExtensionComponent } from '@lexical/react/useExtensionComponent';
import { jsx } from 'react/jsx-runtime';
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/**
* A convenient way to get an Extension's output Component with {@link useExtensionComponent}
* and construct it in one step.
*
* @example
* Usage
* ```tsx
* return (
* <ExtensionComponent
* lexical:extension={TreeViewExtension}
* viewClassName="tree-view-output" />
* );
* ```
*
* @example
* Alternative without ExtensionComponent
* ```tsx
* const TreeViewComponent = useExtensionComponent(TreeViewExtension);
* return (<TreeViewComponent viewClassName="tree-view-output" />);
* ```
*/
function ExtensionComponent({
'lexical:extension': extension,
...props
}) {
const Component = useExtensionComponent(extension);
return /*#__PURE__*/jsx(Component, {
...props
});
}
export { ExtensionComponent };