reflex icon indicating copy to clipboard operation
reflex copied to clipboard

pc.html can't accept state vars

Open Alek99 opened this issue 2 years ago β€’ 3 comments
trafficstars

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

To Reproduce Steps to reproduce the behavior:

  • Code/Link to Repo:
import pynecone as pc

class State(pc.State):
   example_html = """
    <div>
        <h1>Pynecone</h1>
        <p>Pynecone is a Python library for creating web apps.</p>
        <p>It is designed to be easy to use and to be able to create complex apps with minimal code.</p>
        <p>It is also designed to be easy to extend and customize.</p>
    </div>
    """

def index():
    return pc.center(
        pc.html(
            State.example_html 
        )
    )

app = pc.App(state=State)
app.add_page(index)
app.compile()

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

Should work be able to take in a state var as input but getting the error below.

TypeError: Invalid var passed for prop dangerouslySetInnerHTML, expected type pynecone.var.Var[typing.Dict], got value {'__html': BaseVar(name='example_html', type_=<class 'str'>, state='state', is_local=False, is_string=False)} of type <class 'dict'>.

** Specifics (please complete the following information):**

  • Python Version: 3.11
  • Pynecone Version: 0.1.18
  • OS: Darwin

Alek99 avatar Feb 27 '23 21:02 Alek99

@Alek99 I test in the main branch, and it is fine.

d29107d avatar Mar 06 '23 03:03 d29107d

Ok may have been fixed let me lets and I'll close this.

Alek99 avatar Mar 07 '23 01:03 Alek99

I'm still getting this error, will put up a fix for it now

Alek99 avatar Mar 07 '23 01:03 Alek99

I found a workaround for this bug. Example here

csears avatar Mar 25 '23 15:03 csears

I think this issue needs to be reopened.

jq6l43d1 avatar Jun 09 '23 04:06 jq6l43d1