Get the React hooks for this component and its children. Returns: The code that should appear just before returning the rendered component.
(self)
| 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. |