rescript-lang.org icon indicating copy to clipboard operation
rescript-lang.org copied to clipboard

feat: document `ref` for self-referencing

Open czabaj opened this issue 11 months ago • 2 comments

I encountered a problem with valid JS code that was hard to translate into rescript - the problem is discussed here in the forum - it turned out the ref can help with self-referencing.

I promised to add this trick to the documentation, so here it is. Feel free to criticize 😸

I currently added it just to the v11 docs, once this passes validation, I will copy that into other versions as well. I assume it is useful for all versions where mutable let assignment exists?

Here is how it renders

Screenshot 2025-01-03 at 12 38 39

czabaj avatar Jan 03 '25 11:01 czabaj

@czabaj is attempting to deploy a commit to the ReScript Association Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jan 03 '25 11:01 vercel[bot]

Sorry I missed this during my christmas break.

The example seems pretty heavy and we usually try to avoid React-specific code in the main documentation. Can you come up with a simpler example that doesn't need React?

fhammerschmidt avatar Jan 15 '25 13:01 fhammerschmidt