Skip to content

Commit

Permalink
Update based on the new onChange func
Browse files Browse the repository at this point in the history
  • Loading branch information
amitbadala committed Oct 26, 2023
1 parent 7dc66b8 commit 3cc4ec8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
20 changes: 6 additions & 14 deletions examples/for-tests/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,8 @@ const customFields = [
{
id: "ratings",
label: "Ratings",
inputComponent: ({ value, name, ...rest }) => (
<select
name={name}
data-supertokens="inputComponent"
placeholder="Add Ratings"
onChange={(e) => rest.onChange({ id: name, value: e.target.value })}>
inputComponent: ({ name, onChange }) => (
<select name={name} onChange={(e) => onChange(e.target.value)} placeholder="Add Ratings">
<option value="" disabled hidden>
Select an option
</option>
Expand All @@ -190,25 +186,21 @@ const customFields = [
},
{
id: "terms",
showLabels: false,
label: "",
optional: false,
inputComponent: ({ value, name, ...rest }) => (
inputComponent: ({ name, onChange }) => (
<div
data-supertokens="inputComponent"
style={{
display: "flex",
alignItems: "center",
justifyContent: "left",
}}>
<input
name={name}
type="checkbox"
onChange={(e) => rest.onChange({ id: name, value: e.target.checked })}></input>
<input name={name} type="checkbox" onChange={(e) => onChange(e.target.checked.toString())}></input>
<span style={{ marginLeft: 5 }}>I agree to the terms and conditions</span>
</div>
),
validate: async (value) => {
if (value === true) {
if (value === "true") {
return undefined;
}
return "Please check Terms and conditions";
Expand Down
10 changes: 2 additions & 8 deletions lib/build/passwordless-shared3.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ function PhoneNumberInput({
const handleChange = useCallback(
(newValue: string) => {
if (onChangeRef.current !== undefined) {
onChangeRef.current({
id: name,
value: newValue,
});
onChangeRef.current(newValue);
}
},
[onChangeRef]
Expand All @@ -83,10 +80,7 @@ function PhoneNumberInput({
const handleCountryChange = useCallback(
(ev) => {
if (onChangeRef.current !== undefined && phoneInputInstance !== undefined) {
onChangeRef.current({
id: name,
value: ev.target.value,
});
onChangeRef.current(ev.target.value);
}
},
[onChangeRef]
Expand Down

0 comments on commit 3cc4ec8

Please sign in to comment.