rescript-react
rescript-react copied to clipboard
Have a way to create components with props = domProps
There are use-cases where you want to create components that replicate native dom elements, such as <button>, <a>, etc.
For that, you'd need something like ReactDOM.domProps, but as a @obj makeProps binding.
Maybe this issue is not relevant when we finally ship JSX v4, but would still be great to have a streamlined solution for current JSX v3 users.
Related discussions:
- https://forum.rescript-lang.org/t/return-component-from-hook-bind-to-component-with-ref-to-div/2383/8
Hey @ryyppy
Jumping into this issue just to propose a solution
A possible solution to this is to have a decorator that generates the list of props the same way as makeProps does. In styled-ppx I need to exactly do that, so all HTML element's props remain available from the outside: https://github.com/davesnx/styled-ppx/blob/main/packages/ppx/src/makeProps.re.
I'm not saying that should be fixed, just proposing a solution!
@ryyppy This is not an issue in JSX 4 anymore, right?
So with JSX 4 around the corner, can this be closed?
@ryyppy Just tested, this is indeed possible with JSX 4:
module MyDiv = {
type props = JsxDOM.domProps
let make = props => <div {...props} />
}