Closed DunetsNM closed 1 month ago
this fixes #241
To avoid impacting too much the bundle size, we could extract the method body into a function and pass it the typeof<'Props>.FullName
+ all the required information as an argument.
What do you think?
@MangelMaxime I moved the fat part to Cache.GetOrAdd to avoid creating more public/inlineable impl functions
Thank you
User code that invokes
FunctionComponent.Of
can also be in generic context which makes caching by source FileName+LineNumber unsuitable: one function gets cached and resolved at runtime for different runtime types which results in runtime exceptions.I propose to add
'Props
type name to the cache key to fix that.You still can write code were wrong function will be picked up at runtime for the same 'Props argument type (e.g. if different
render
func values are passed from the outside), but it's less likely to happen.Ultimate solution would be to expose the fact that function is prepared and cached to the users and let them to specify their own unique cache key - or piggyback on existing
displayName
, which is also not ideal.