Skip to content

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

@jq6l43d1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions