reflex icon indicating copy to clipboard operation
reflex copied to clipboard

about add_hooks: _get_added_hooks make _get_all_hooks's return wrong

Open seewindcn opened this issue 1 year ago β€’ 0 comments

Describe the bug A clear and concise description of what the bug is.

    def _get_added_hooks(self) -> dict[str, imports.ImportDict]:
         ....

    def _get_all_hooks(self) -> dict[str, None]:
        """Get the React hooks for this component and its children.

        Returns:
            The code that should appear just before returning the rendered component.
        """
        code = {}

        # Add the hook code for this component.
        hooks = self._get_hooks()
        if hooks is not None:
            code[hooks] = None

        code.update(self._get_added_hooks())
        ......
        return code

_get_added_hooks will return dict[str, imports.ImportDict], it is be called by _get_all_hooks, and code.update(self._get_added_hooks()), this make code's content wrong, code will be dict[str, ImportDict].

To Reproduce

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version:
  • Reflex Version:
  • OS:
  • Browser (Optional):

Additional context Add any other context about the problem here.

seewindcn avatar May 22 '24 02:05 seewindcn