Skip to content

Commit d6f727a

Browse files
Set React's onChange property for input elements if its not provided
1 parent 178fc05 commit d6f727a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: src/js/packages/@reactpy/client/src/components.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ function UserInputElement({ model }: { model: ReactPyVdom }): JSX.Element {
101101
// allow the client to respond (and possibly change the value)
102102
givenOnChange(event);
103103
};
104+
} else if (!givenOnChange) {
105+
props.onChange = (event: ChangeEvent<any>) => {
106+
// set the value so rerender doesn't stomp on state
107+
setValue(event.target.value);
108+
}
104109
}
105110

106111
// Use createElement here to avoid warning about variable numbers of children not

0 commit comments

Comments
 (0)