@zouloux First, thank you very much for your proposal and sharing your ideas with everybody.
There have already been some propsals using the factory pattern, but yours is the first one that passes a "props" function to the factory and returns a render function that has no arguments - that seems a good idea to me (actually, I myself once proposed a factory with a "initialProps" object argument and a render function with a "props" object, which was not a good idea and was not powerful enough - but your proposal fixes those issues and is way better).
My question:
When using the current React hook API you often have custom hooks where you pass values, like useSomeCustomHook(a, b, c). Let's say in this example a, b and c are strings. Using your proposal a, b and c would have to be getter functions. Don't you think that makes things kind of complicated? For example: useSomeOtherCustomHook(() => props().title)
That's currently my main concern about using a factory pattern (not only in your proposal).
@zouloux First, thank you very much for your proposal and sharing your ideas with everybody. There have already been some propsals using the factory pattern, but yours is the first one that passes a "props" function to the factory and returns a render function that has no arguments - that seems a good idea to me (actually, I myself once proposed a factory with a "initialProps" object argument and a render function with a "props" object, which was not a good idea and was not powerful enough - but your proposal fixes those issues and is way better).
My question: When using the current React hook API you often have custom hooks where you pass values, like
useSomeCustomHook(a, b, c)
. Let's say in this examplea
,b
andc
are strings. Using your proposala
,b
andc
would have to be getter functions. Don't you think that makes things kind of complicated? For example:useSomeOtherCustomHook(() => props().title)
That's currently my main concern about using a factory pattern (not only in your proposal).