Skip to main content

ReactApp

Function ReactApp 

Source
pub fn ReactApp(_: ReactAppProps) -> Element
Expand description

React application container — loads a React app from a folder asset + manifest.

Uses Dioxus’s folder asset feature to reference the entire React build output directory. The manifest describes which CSS/JS files to load (with their hashed filenames), so no renaming or copying is needed.

The component:

  1. Loads all stylesheets listed in the manifest
  2. Injects the IPC bridge script (if provided)
  3. Creates the mount point <div> and loads all JS bundles

§Example

use dioxus::prelude::*;
use dioxus_react_integration::prelude::*;
use std::time::Duration;

const REACT_DIR: Asset = asset!("/assets/react");

fn app() -> Element {
    let bridge = IpcBridge::builder()
        .timeout(Duration::from_secs(30))
        .build();

    let manifest = ReactManifest::from_json(
        include_str!("../assets/react/metadata.json")
    ).expect("invalid metadata.json");

    rsx! {
        ReactApp {
            dir: REACT_DIR,
            manifest: manifest,
            bridge: bridge,
        }
    }
}

§Props

For details, see the props struct definition.

  • dir : Asset

    Folder asset pointing to the React build output directory

  • manifest : ReactManifest

    Build manifest with the hashed filenames

  • bridge : Option<crate::prelude::IpcBridge>

    Optional IPC bridge instance (generates and injects the bridge script)

  • mount_id : String

    DOM element ID where React will mount (default: “root”)