Re:How to write PureScript react components to replace JavaS...
by ddek on Friday June 26, 2020 @04:32AM
(#23649911)
There is a change I’d make though - I’d memo-ise the click handler with useCallback. By using the function ‘overload’ on setState, which is guaranteed not to change, the callback will only be calculated (?) when the onclick handler changes. The setState would look like this: setState(c => c + 1);. Right now, the callback is interpreted on every render cycle.
You can add types if you want. And maybe one can discuss if there is a more elegant syntax than the C-style syntax of JavaScript (there is ...).
Other than that. I think the code is about as concise as it gets.