Skip to content

Error when setting rx.code_block with can_copy=True in the markdown component map #3880

Closed

Description

@jq6l43d1

Describe the bug
when setting rx.code_block with can_copy=True in the markdown component map, in the browser, an unhandled error will be raised. "ReferenceError: RadixThemesButton is not defined"

To Reproduce
Steps to reproduce the behavior:


component_map = {
    "codeblock": lambda text, **props: rx.code_block(
        text, **props, can_copy=True,
    ),
}

def index():
    return rx.vstack(
        rx.markdown(
            r"""
\```python
import reflex as rx

component = rx.text("Hello World!")
\```
""",
            component_map=component_map,
        ),
        rx.code_block(
            """def fib(n):
            if n <= 1:
                return n
            else:
                return(fib(n-1) + fib(n-2))""",
            language="python",
            # can_copy=True, # If this is commented out, an unhandled error will be raised. ReferenceError: RadixThemesButton is not defined
        ),
    )

app = rx.App()
app.add_page(index)

Expected behavior
The page should be rendered without an error.

Specifics (please complete the following information):

  • Python Version: 3.12.3
  • Reflex Version: 0.5.10
  • OS: Ubuntu 24.04

Additional context
If I include an rx.code_block with the can_copy=True flag on the same page, the page is rendered correctly.

Activity

  1. added
    bug
    on Sep 4, 2024
  2. added a commit that references this issue on Sep 4, 2024
    952c438
  3. added a commit that references this issue on Sep 5, 2024
    cbe532c
  4. added a commit that references this issue on Sep 6, 2024
    7d79943
  5. added 2 commits that reference this issue on Sep 9, 2024
    7ad4016
    a5c73ad
  6. added a commit that references this issue on Sep 11, 2024
    95631ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions