Closed gunar closed 4 years ago
The render()
method is already basically that, and the class allows for the declaration of properties.
Is there any specific you're trying to achieve with a pure function?
If you don't want classes, and would prefer a functional approach like React, you could just use Lit-Html. Lit-Element uses it under the hood to render the DOM: https://lit-html.polymer-project.org. It's really small, something like 3KB, and much faster than React at rendering. You can use it with Redux, using same patterns as React. But you'd be missing out on all the things that make Web components so great. Web Components are part of the browser platform. The DOM is object-oriented (Document Object Model), so it's class-based. Even though you might be using what you think are class-free techniques in JavaScript, such as using literals to create objects, arrays, etc., under the hood those are aliased to constructors that create new instances.
Would be interesting to able to define components as pure functions—as opposed to extending classes.