Catch a JS Error + code cleanup (#384)
This commit is contained in:
parent
1ab8620852
commit
39732d12f5
@ -13,3 +13,28 @@ class Icon(ChakraIconComponent):
|
|||||||
"""An image icon."""
|
"""An image icon."""
|
||||||
|
|
||||||
tag = "None"
|
tag = "None"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create(cls, *children, **props):
|
||||||
|
"""Initialize the Icon component.
|
||||||
|
|
||||||
|
Run some additional checks on Icon component.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
children: The positional arguments
|
||||||
|
props: The keyword arguments
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
AttributeError: The errors tied to bad usage of the Icon component.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The created component.
|
||||||
|
"""
|
||||||
|
if children:
|
||||||
|
raise AttributeError(
|
||||||
|
f"Passing children to Icon component is not allowed: remove positional arguments {children} to fix"
|
||||||
|
)
|
||||||
|
if "tag" not in props.keys():
|
||||||
|
raise AttributeError("Missing 'tag' keyword-argument for Icon")
|
||||||
|
|
||||||
|
return super().create(*children, **props)
|
||||||
|
@ -27,9 +27,9 @@ class HydrateMiddleware(Middleware):
|
|||||||
An optional state to return.
|
An optional state to return.
|
||||||
"""
|
"""
|
||||||
if event.name == utils.get_hydrate_event(state):
|
if event.name == utils.get_hydrate_event(state):
|
||||||
route = event.router_data.get("pathname", "")
|
route = event.router_data.get(constants.RouteVar.PATH, "")
|
||||||
if route == "/":
|
if route == "/":
|
||||||
load_event = app.load_events.get("index")
|
load_event = app.load_events.get(constants.INDEX_ROUTE)
|
||||||
elif route:
|
elif route:
|
||||||
load_event = app.load_events.get(route.lstrip("/"))
|
load_event = app.load_events.get(route.lstrip("/"))
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user