Editor for React
React version of this topic (compatible with React 19+). Keep the same configuration logic from JavaScript and pass it as component props.
What this topic covers: practical setup, the framework-specific API access pattern, and copy-adapt guidance for the examples in this page.
import React, { useMemo, useRef } from 'react';
import { Editor } from 'smart-webcomponents-react/editor';
import 'smart-webcomponents-react/source/styles/smart.default.css';
export default function App() {
const componentRef = useRef(null);
const componentProps = useMemo(() => ({
// Copy this topic's JavaScript configuration here.
}), []);
return <Editor ref={componentRef} {...componentProps}></Editor>;
}
Use componentRef.current for API methods in this topic.
Build your web apps using Smart UI Library
Smart.Editor - iFrame Mode
iFrame Editor
Smart.Editor's content section can be easily stylied or modifed via CSS or Javascript. However the Editor has an additional iframe mode which places the Editor's content inside an iframe which provides an isolated DOM that does not allow styles and scripts to leak in.
The iframe mode is not enabled by default. A property of type object called iframeSettings that configures the iframe mode with the following settings:
- enabled - determines whether iframe mode is enabled or not.
- attributes - an object that defines attributes for the iframe, for example:
attributes: { height: 500 }All native iframe attributes are supported.
-
resources - an object that determines what styles and scripts should be imported into the
iframe's DOM. For example:
resources: { 'style': { href: 'styles.css' }, 'script': { src: 'index.js', type: 'module' } }The href and src attributes should point to the file location and name.
The type attribute determines whether the JS file should be loaded as a module or not.
For AI tooling
Developer Quick Reference
Topic: editor-iframe-mode Component: Editor Framework: React
Main methods: (none detected)
Common config keys: (none detected)
Implementation Notes
Compatibility: React 19+ API access pattern: const componentRef = useRef(null) + componentRef.current.method()
Lifecycle guidance: Use useMemo for large config objects and call imperative API through componentRef.current after first render.
Common pitfalls:
- Recreating columns/dataSource objects on every render can reset component state.
- Calling API methods before ref is available causes runtime errors.
- Mixing controlled and imperative updates without sync can lead to stale UI.
Validation checklist:
- Keep config objects memoized when possible.
- Guard API calls with ref existence checks.
- Verify CSS theme import is present once per app.