Comments (4)
Sure, opened rescript-lang/rescript-compiler#6007, thanks.
from rescript-react.
I think useCallback takes functions with 1 argument.
That said, that code should not be generated.
Could you try to define the callback function separately, instead of inlining it, and see what the generated code looks like. That would be a useful test to determine the scope of what's going on.
from rescript-react.
Thanks @cristianoc, I wasn't aware of that restriction wrt useCallback but extracting the function does produce valid JS:
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);
};
});
from rescript-react.
Thanks. So the issue is contained to async functions auto curried when inlined. Would you move this issue to the compiler repo?
For the specific example, useCallback2 seems like the way to go.
from rescript-react.
Related Issues (20)
- Support react@canary release HOT 7
- `suppressHydrationWarning` does not belong to type JsxDOM.domProps
- Scroll Restoration
- Implicit type conversion?
- Checking backward compatibility with JSX PPX V4 HOT 2
- Expose ReactDOM.Props.domProps separately and concat? HOT 2
- Implementation ErrorBoundary component with jsx ppx HOT 4
- ReactDOMServer.renderToString ... server.js not exported from react-dom HOT 1
- Split into multiple packages? HOT 8
- Props types cleanup HOT 25
- V3 compatibility does not seem to work with lowercase JSX HOT 11
- Breaking change of key type
- Put JSX 4 PPX support functions into a separate module HOT 7
- Any plan to support `React.lazy`? HOT 1
- Can I use async in event handler? HOT 3
- publish 11.0 to npm? HOT 1
- RescriptReactErrorBoundary not working in v0.11 HOT 1
- Bindings to React modules are incompatible with node ESM HOT 1
- children type incorrect for Fragment, StrictMode and Suspense
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rescript-react.