I think you may have answered your question, re. DRY. :) There are other benefits to pure functions in a more general sense, but I think here DRY more or less covers it: The design allows us to place all of our code that changes state and produces side-effects in one place. It means our forms become much simpler to write and understand.
I don't know if there is an insistence on making every form a pure function, but it seems to be a natural and beneficial aspect of the design.
I would just add that with this pattern you get all the benefits of stateless functional components.
See this article (he notes that pure functions become easier to reason about, in functional programming jargon, "referential transparency"): hackernoon.com/react-stateless-fun...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Interesting technique. I like how it DRY's up the code.
What are the benefits of insisting on forms being pure functions in this particular scenario?
Hi @avremel ,
I think you may have answered your question, re. DRY. :) There are other benefits to pure functions in a more general sense, but I think here DRY more or less covers it: The design allows us to place all of our code that changes state and produces side-effects in one place. It means our forms become much simpler to write and understand.
I don't know if there is an insistence on making every form a pure function, but it seems to be a natural and beneficial aspect of the design.
Agreed.
I would just add that with this pattern you get all the benefits of stateless functional components.
See this article (he notes that pure functions become easier to reason about, in functional programming jargon, "referential transparency"):
hackernoon.com/react-stateless-fun...