File tree 2 files changed +4
-3
lines changed
examples/cli/.perseus/src
2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,13 @@ pub fn run() -> Result<(), JsValue> {
25
25
// Create a mutable translations manager to control caching
26
26
let translations_manager =
27
27
Rc :: new ( RefCell :: new ( ClientTranslationsManager :: new ( & get_locales ( ) ) ) ) ;
28
+ // Get the error pages in an `Rc` so we aren't creating hundreds of them
29
+ let error_pages = Rc :: new ( get_error_pages ( ) ) ;
28
30
29
31
sycamore:: render_to (
30
32
|| {
31
33
template ! {
32
34
BrowserRouter ( move |route: AppRoute | {
33
- // TODO improve performance rather than naively copying error pages for every template (use `Rc<ErrorPages>`)
34
35
match route {
35
36
// We handle the 404 for the user for convenience
36
37
AppRoute :: NotFound => get_error_pages( ) . get_template_for_page( "" , & 404 , "not found" ) ,
@@ -44,7 +45,7 @@ pub fn run() -> Result<(), JsValue> {
44
45
locale,
45
46
// We give the app shell a translations manager and let it get the `Rc<Translator>` (because it can do async safely)
46
47
Rc :: clone( & translations_manager) ,
47
- get_error_pages ( )
48
+ Rc :: clone ( & error_pages )
48
49
)
49
50
}
50
51
}
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ pub fn app_shell(
115
115
// translator: Rc<Translator>,
116
116
locale : String ,
117
117
translations_manager : Rc < RefCell < ClientTranslationsManager > > ,
118
- error_pages : ErrorPages ,
118
+ error_pages : Rc < ErrorPages > ,
119
119
) -> Template < DomNode > {
120
120
// Get the container as a DOM element
121
121
let container = NodeRef :: new ( ) ;
You can’t perform that action at this time.
0 commit comments