News for hackers. Stuff that matters.
Re:Goodbye, Object Oriented Programming by quacker on Sunday July 24, 2016 @03:47PM (#12154522)
My impression of react is that it's very object oriented. Defining reusable, stateful components is classic OO design. Now, I don't have much experience with React so maybe someone can explain why it should be considered "functional".
Re:Goodbye, Object Oriented Programming by acemarke on Sunday July 24, 2016 @03:52PM (#12154552)
React is an interesting mix of functional and OO. It's OO, in that the primary approach for defining components is class-based, and components have state and lifecycles. It's functional, in that the render methods are expected to be pure functions based on component state and props, and simply output a description of what the UI should look like as a result. Also, as a whole, React definitely pushes you to view the system in terms of composition, state transformations, and pure functions, rather than imperative "toggle this, add that, update the other thing".
Re:Goodbye, Object Oriented Programming by TheOtherHobbes on Sunday July 24, 2016 @05:03PM (#12154886)
Maybe we need a new tag: OOF.

Or possibly FOO.

Re:Goodbye, Object Oriented Programming by jaegerpicker on Sunday July 24, 2016 @08:49PM (#12155788)
Not sure why people have that impression. It doesn't fundamentally do any OO things. You don't inherit from the react components. Maybe you could make an argument for encapsulation but even that is shaky in JavaScript. Most it only uses prototypes as object for namespacing and to organize the api better since JS lacks good namespacing syntax.
Re:Goodbye, Object Oriented Programming by danek on Monday July 25, 2016 @08:06PM (#12162460)
It depends on how you use React. You can use it in a stateful, OO way. Or you can use it in a more functional way. A good example of how to use React in a functional manner is the Redux framework (basically you don't use the stateful parts of React and treat your components as a tree of pure render functions). http://redux.js.org/