Passing a client event handler directly from an RSC
While you cannot directly use inline handlers in RSCs, you may pass ones imported from 'use client'; files. I used to have an intermediary client component before I figured out this is possible.
The first row of numbers will increment (handler does direct HTML mutation). Second row takes box color and applies it to page's. Third button has a handler that fetches ip and then displays it via browser's `alert` API.
Note that you cannot pass values directly to the imported functions (no wrapping functions, nor binding.) but you can still utilize element attributes (content itself, style, and most importantly datasets) to inline data that the handler can then pick up.
- 1
- 2
- 3
- 4
- .
- .
- .
- .