| 1989 | def 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)", |