Closed ArtemyB closed 8 months ago
Hi @ArtemyB I understand the generated JS is not ideal by Feliz, however sometimes it is not possible to inline members. I don't remember the exact reasons why some hooks aren't being inlined. That said, a PR would be really appreciated that includes these improvements 🙏
Here are the examples of React hook calls currently (
Feliz v2.4.1
, but I remember the case take place all myFeliz
usage):useReact_useCallback_1CA17B65
,useReact_useMemo_10C6A43C
and so on. Firstly, That doesn't look pretty. And in practice it affects React Dev Tools user experience. Secondly, there is actual JS-code being produced in Feliz bundle, e.g. fromfable_modules/Feliz.2.4.1/React.fs.js
:As I understand, this would not have happened if the containing
React
type hadErase
attribute (to be erased by Fable). However it will work only when all of the type members areinline
. And now I see that alongside theinline
"pure" importsReact
type contains:inline
members that in fact could be madeinline
because of being "pure" imports);inline
members and even custom hooks with the actual logic (createDisposable
,useEffectOnce
,useCallbackRef
,useCancellationToken
) that couldn't be simply markedinline
while being defined directly in theReact
type as they're now. However I see the solution in moving all these custom hooks to a separate module/non-erased type and then calling them from theinline
members ofReact
type -- so that there should be no critical changes from the F# API perspective. P.S. AlsoHook
attribute should be removed from all these hook-members when theReact
type is erased.The solution doesn't seems to require a lot of work, if it is actually correct -- haven't tried anything yet, just made assumptions based on my previous experience. Decided to ask for other opinions and expertise here before doing something 🙂