-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Question: How to make asynchronous calls from a form submit? #178
Comments
Is this issue that you're waiting for Duplicate of #105 |
Likely I am interpreting this wrong but it sounds like there is only one license plate number entered at a time. Could you just use one Recoil atom to represent the current licence plate number. Or is there another reason why you were looking to use selectorFamily? const currentLicensePlate = atom({
key: "currentLicensePlate",
default: null,
});
const dataForCurrentLicensePlate = selector({
key: "currentLicensePlateData",
get({ get }) {
const lpn = get(currentLicensePlate);
if (lpn === null) {
return null;
}
return axios.get("/data", {
params: {
license: lpn,
},
});
},
});
function MyComponent() {
const setCurrentLicense = useSetRecoilState(currentLicensePlate);
const [input, setInput] = useState("");
return (
<>
<input type="text" value={input} onChange={setInput} />
<button onClick={() => setCurrentLicense(input)}>Submit</button>
</>
);
}
function ShowData() {
const data = useRecoilValue(dataForCurrentLicensePlate);
return <pre>{JSON.stringify(data)}</pre>;
} |
@jimmyandrade - Please feel free to re-open if the suggestions here don't help! |
I am building an application to check for traffic tickets for a specific car.
It should work as follows:
axios
.I was trying to use the car license plate number as the argument using
selectorFamily
, but it is still not available (#105). So... any thoughts about how to implement this usingrecoil
?The text was updated successfully, but these errors were encountered: