zouloux / prehook-proof-of-concept

This is a proof of concept of a React Hook like implementation for Preact.
MIT License
33 stars 2 forks source link

Just questions #2

Closed mcjazzyfunky closed 6 years ago

mcjazzyfunky commented 6 years ago

@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).

mcjazzyfunky commented 6 years ago

I've added the question to #1 - so we can discuss the question there and I will close #2.