Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Stencil is different from React and Angular?

I am familiar with Angular and know basics of React. I was exploring stencil docs, I found stencil component has both @Component decorator and render() method -

component.tsx

import { Component, Prop } from '@stencil/core';  @Component({     tag: 'my-first-component',     styleUrl: 'my-first-component.scss' }) export class MyComponent {     // Indicate that name should be a public property on the component     @Prop() firstName: string;      render() {         return (             <p>             My name is {this.firstName}             </p>         );     } }  

Help me to understand that how Stencil is different from angular and react and how it works?

like image 322
Swapnil Patwa Avatar asked Aug 23 '17 12:08

Swapnil Patwa


People also ask

What is Stencil in React?

Stencil provides a wrapper for your custom elements to be used as first-class React components. The goal of a wrapper is to easily integrate your Stencil components into a specific framework.

What is Stencil in Angular?

Stencil can generate Angular component wrappers for your web components. This allows your Stencil components to be used within an Angular application.

Why is Stencil not a framework?

Is Stencil a framework? Stencil purposely does not strive to act as a stand-alone framework, but rather a tool which allows developers to scale framework-agnostic components across many projects, teams and large organizations.

How is ReactJS different from Angular?

React is a library, but Angular is a full-fledged framework. The virtual DOM and one-way data binding are used by React. js, but the real DOM and two-way data binding are used by Angular. There's also a speed difference (React's is faster) and a difference in bundle size (React's is smaller) (React works a bit faster).


1 Answers

Stencil is not a framework, its just a compiler that turns classes with decorators into standards-based Web Components. This means that you can generate a collection of stencil components and use them in Angular, React, Vue or Polymer without any problem.

Basically, Stencil combines some of the best features from traditional frameworks, but outputs 100% standards-compliant Custom Elements, thats why you have @Component (Angular), render method (React)...

To make your first component i suggest to read the docs about your first component. You have everything explained there :)

like image 124
Fernando Del Olmo Avatar answered Sep 24 '22 03:09

Fernando Del Olmo