reflex-examples icon indicating copy to clipboard operation
reflex-examples copied to clipboard

Syntax error in home.js in the GPT example

Open jochemloedeman opened this issue 2 years ago • 1 comments

Upon compiling the /home route in the GPT example, I am getting

error - ./pages/home.js
Error: 
  x Expected ident
    ,----
 82 | <DataTableGrid columns={state.["Question", "Answer"]}
    :                               ^
    `----

Caused by:
    0: failed to process input file
    1: Syntax Error

Manually removing the state. prefix to the columns argument seems to yield valid syntax.

I am using Pynecone 0.1.20 with Node.js 18.15.0 on a MacBook Pro M1 Pro.

jochemloedeman avatar Mar 17 '23 15:03 jochemloedeman

add this line to State

# like this
class State(pc.State):
    show_columns = ["Question", "Answer"]

and change the pc.data_table columns to this

pc.data_table(
    data=State.questions,
    columns=State.show_columns,
    ...
)

and it's worked

Weibin74 avatar Mar 21 '23 05:03 Weibin74