reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Throw better error message for invalid event handler signature

Open picklelo opened this issue 3 years ago β€’ 0 comments

Some event handlers are expected an argument.

For example when setting an input, you need


class State(pc.State):
    text: str
    
    def change_text(self, text):
        self.text = text.upper()

Then call it with


pc.input(on_change=State.change_text)

But if by mistake you define your event handler as


def change_text(self):
    self.text = text.upper()

it throws a gross list index error. This should instead be a nice clean error message.

picklelo avatar Jan 26 '23 10:01 picklelo