MCPcopy Create free account
hub / github.com/dot-agent/nextpy / get_hooks

Method get_hooks

nextpy/frontend/components/component.py:1004–1022  ·  view source on GitHub ↗

Get the React hooks for this component and its children. Returns: The code that should appear just before returning the rendered component.

(self)

Source from the content-addressed store, hash-verified

1002 return
1003
1004 def get_hooks(self) -> Set[str]:
1005 """Get the React hooks for this component and its children.
1006
1007 Returns:
1008 The code that should appear just before returning the rendered component.
1009 """
1010 # Store the code in a set to avoid duplicates.
1011 code = self._get_hooks_internal()
1012
1013 # Add the hook code for this component.
1014 hooks = self._get_hooks()
1015 if hooks is not None:
1016 code.add(hooks)
1017
1018 # Add the hook code for the children.
1019 for child in self.children:
1020 code |= child.get_hooks()
1021
1022 return code
1023
1024 def get_ref(self) -> str | None:
1025 """Get the name of the ref for the component.

Callers 6

createMethod · 0.45
_get_custom_codeMethod · 0.45
createMethod · 0.45
createMethod · 0.45
test_get_hooks_nestedFunction · 0.45
test_get_hooks_nested2Function · 0.45

Calls 3

_get_hooks_internalMethod · 0.95
_get_hooksMethod · 0.95
addMethod · 0.80

Tested by 2

test_get_hooks_nestedFunction · 0.36
test_get_hooks_nested2Function · 0.36