@@ -373,7 +373,10 @@ def context_template(
373373 """
374374 initial_state = initial_state or {}
375375 state_contexts_str = "" .join (
376- [f"{ state_name } : createContext(null)," for state_name in initial_state ]
376+ [
377+ f"{ format_state_name (state_name )} : createContext(null),"
378+ for state_name in initial_state
379+ ]
377380 )
378381
379382 state_str = (
@@ -424,17 +427,18 @@ def context_template(
424427 )
425428
426429 state_reducer_str = "\n " .join (
427- rf'const [{ state_name } , dispatch_{ state_name } ] = useReducer(applyDelta, initialState["{ state_name } "])'
430+ rf'const [{ format_state_name ( state_name ) } , dispatch_{ format_state_name ( state_name ) } ] = useReducer(applyDelta, initialState["{ state_name } "])'
428431 for state_name in initial_state
429432 )
430433
431434 create_state_contexts_str = "\n " .join (
432- rf"createElement(StateContexts.{ state_name } ,{{value: { state_name } }},"
435+ rf"createElement(StateContexts.{ format_state_name ( state_name ) } ,{{value: { format_state_name ( state_name ) } }},"
433436 for state_name in initial_state
434437 )
435438
436439 dispatchers_str = "\n " .join (
437- f'"{ state_name } ": dispatch_{ state_name } ,' for state_name in initial_state
440+ f'"{ state_name } ": dispatch_{ format_state_name (state_name )} ,'
441+ for state_name in initial_state
438442 )
439443
440444 return rf"""import {{ createContext, useContext, useMemo, useReducer, useState, createElement, useEffect }} from "react"
@@ -443,7 +447,7 @@ def context_template(
443447
444448export const initialState = { "{}" if initial_state else json_dumps (initial_state )}
445449
446- export const defaultColorMode = { default_color_mode }
450+ export const defaultColorMode = { default_color_mode }
447451export const ColorModeContext = createContext(null);
448452export const UploadFilesContext = createContext(null);
449453export const DispatchContext = createContext(null);
@@ -830,16 +834,5 @@ def render(self, **kwargs) -> str:
830834# Code to render StatefulComponent to an external file to be shared
831835STATEFUL_COMPONENTS = TemplateFunction (_stateful_components_template )
832836
833- # Sitemap config file.
834- SITEMAP_CONFIG = "module.exports = {config}" .format
835-
836837# Code to render the root stylesheet.
837838STYLE = TemplateFunction (_styles_template )
838-
839- # Template containing some macros used in the web pages.
840- MACROS = TemplateFunction (
841- lambda ** kwargs : _render_hooks (
842- kwargs .get ("hooks" , {}),
843- kwargs .get ("memo" , None ),
844- )
845- )
0 commit comments