File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,6 +211,20 @@ fn App() -> Element {
211211 }
212212}
213213
214+ /// Force the children to only render on the client
215+ #[ component]
216+ fn ClientOnly ( children : Element ) -> Element {
217+ let mut on_client = use_signal ( || false ) ;
218+
219+ use_effect ( move || on_client. set ( true ) ) ;
220+
221+ if on_client ( ) {
222+ children
223+ } else {
224+ rsx ! { }
225+ }
226+ }
227+
214228#[ derive( Routable , Clone , PartialEq ) ]
215229enum Route {
216230 #[ route( "/" ) ]
@@ -715,13 +729,15 @@ fn Playground(
715729 }
716730 }
717731 }
718- CodeEditor {
719- value: source( ) ,
720- language: Language :: Rust ,
721- theme,
722- aria_label: "Rust source editor" ,
723- class: "playground-code-editor" ,
724- oninput: move |value| source. set( value) ,
732+ ClientOnly {
733+ CodeEditor {
734+ value: source( ) ,
735+ language: Language :: Rust ,
736+ theme,
737+ aria_label: "Rust source editor" ,
738+ class: "playground-code-editor" ,
739+ oninput: move |value| source. set( value) ,
740+ }
725741 }
726742 }
727743 }
You can’t perform that action at this time.
0 commit comments