-
Notifications
You must be signed in to change notification settings - Fork 471
Closed
Milestone
Description
Thank you for filing! Check list:
- Is it a bug? Usage questions should often be asked in the forum instead.
- Concise, focused, friendly issue title & description.
- A minimal, reproducible example.
- [] OS and browser versions, if relevant.
- Is it already fixed in master? Instructions
see: rescript-lang/rescript-react#89
I noticed that when passing this async function:
let onSubmit = React.useCallback(async (_a, _b) => {
await Promise.resolve()
})it results in the following JS code which does not compile as the function is not async:
var onSubmit = React.useCallback(function (_a) {
return function (_b) {
return await Promise.resolve(undefined);
};
});the issue can be avoided by assigning the callback to a variable:
let cb = async (_a, _b) => {
await Promise.resolve()
}
let onSubmit = React.useCallback(cb)compiles to:
async function cb(_a, _b) {
return await Promise.resolve(undefined);
}
var onSubmit = React.useCallback(function (param) {
return function (param$1) {
return cb(param, param$1);
};
});Metadata
Metadata
Assignees
Labels
No labels