MCPcopy
hub / github.com/reflex-dev/reflex / add_hooks

Method add_hooks

tests/units/components/test_component.py:1991–2009  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1989def test_component_add_hooks_var():
1990 class HookComponent(Component):
1991 def add_hooks(self):
1992 return [
1993 "const hook3 = useRef(null)",
1994 "const hook1 = 42",
1995 Var(
1996 _js_expr="useEffect(() => () => {}, [])",
1997 _var_data=VarData(
1998 hooks={
1999 "const hook2 = 43": None,
2000 "const hook3 = useRef(null)": None,
2001 },
2002 imports={"react": [ImportVar(tag="useEffect")]},
2003 ),
2004 ),
2005 Var(
2006 _js_expr="const hook3 = useRef(null)",
2007 _var_data=VarData(imports={"react": [ImportVar(tag="useRef")]}),
2008 ),
2009 ]
2010
2011 assert list(HookComponent.create()._get_all_hooks()) == [
2012 "const hook3 = useRef(null)",

Callers

nothing calls this directly

Calls 3

VarClass · 0.90
VarDataClass · 0.90
ImportVarClass · 0.90

Tested by

no test coverage detected