Handling html attributes not defined in rescript-react

Hello,
I just found out that RescriptReact won’t let me use loading attribute of img tag (w3 docs).
I checked ReactDOM.res file and couldn’t find anything related to this attribute.
I found a nice article about lazy loading images in rescript but it’s a bit overkill for me when I just want to use a simple HTML attribute.
Is there a way to handle an attribute not defined in ReactDOM.res?

3 Likes

I found the solution on the forum here.
It looks weird for defining standard HTML tags attributes but works.

    {React.cloneElement(
      <img src="/path"  />,
      {"loading": "lazy"},
    )}
3 Likes

IIRC this situation is going to improve a lot eventually with some changes to the JSX PPX (or related changes, can’t remember). I know @rickyvetter has been working on this.

2 Likes