+1 vote
in VueJS by
What are functional components?

1 Answer

0 votes
by

The functional components are just simple functions to create simple components just by passing a context. Every functional component follows two rules,

Stateless: It doesn’t keep any state by itself

Instanceless: It has no instance, thus no this

You need to define functional: true to make it functional. Let's take an example of functional components,

Vue.component('my-component', {

  functional: true,

  // Props are optional

  props: {

    // ...

  },

  // To compensate for the lack of an instance,

  // we are now provided a 2nd context argument.

  render: function (createElement, context) {

    // ...

  }

})

Related questions

0 votes
asked Oct 9, 2022 in JavaScript by Robin
0 votes
asked Sep 6, 2023 in VueJS by DavidAnderson
...