MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus / Script

Function Script

packages/document/src/elements/script.rs:92–118  ·  view source on GitHub ↗
(props: ScriptProps)

Source from the content-addressed store, hash-verified

90/// </div>
91#[component]
92pub fn Script(props: ScriptProps) -> Element {
93 use_update_warning(&props, "Script {}");
94
95 use_hook(|| {
96 let document = document();
97 let mut insert_script = document.create_head_component();
98 if let Some(src) = &props.src {
99 if !should_insert_script(src) {
100 insert_script = false;
101 }
102 }
103
104 if !insert_script {
105 return;
106 }
107
108 // Make sure the props are in a valid form - they must either have a source or children
109 if let (None, Err(err)) = (&props.src, props.script_contents()) {
110 // If the script has neither contents nor src, log an error
111 err.log("Script")
112 }
113
114 document.create_script(props);
115 });
116
117 VNode::empty()
118}
119
120#[derive(Default, Clone)]
121struct ScriptContext(DeduplicationContext);

Callers

nothing calls this directly

Calls 8

use_update_warningFunction · 0.85
use_hookFunction · 0.85
documentFunction · 0.85
should_insert_scriptFunction · 0.85
script_contentsMethod · 0.80
logMethod · 0.80
create_head_componentMethod · 0.45
create_scriptMethod · 0.45

Tested by

no test coverage detected