...

/

Functional Components and KeyCode Modifiers

Functional Components and KeyCode Modifiers

Learn why we should avoid functional components and KeyCode modifiers in Vue 2 to enable easier migration.

Functional components

We can create functional components in both versions of Vue. A functional component is stateless and has neither data nor this context. It only has a render function. Thanks to that, functional components are faster to create and cheaper to render.

Let’s run the following code and look at the functional component example in Vue 2:

Note: The code below may take a while to run. When the server starts, go to the app URL to see the output.

import "./examples/functional-component/functional-component";
Functional component example in Vue 2
  • A new Vue instance is created in the functional-components.js file. This Vue instance renders the FunctionalComponentExample component.
  • The FunctionalComponentExample is a functional
...