React is an open-source User Interface (UI) JavaScript library developed by Facebook. Since its inception in 2011, organizations have adopted React to create front-end experiences like mobile apps, websites, and more. Some companies that make use of the React library are Facebook, Airbnb, and Netflix.
React makes it easy to build reusable web applications utilizing component architecture. With this process, debugging is a lot easier because React supports one-way data flow.
import React from 'react'; require('./style.css'); import ReactDOM from 'react-dom'; import App from './app.js'; ReactDOM.render( <App />, document.getElementById('root') );
From the snippet of code above, we set the initial state on the class component and reference the state to render the value on the page. In addition to creating the state, we include a couple of div
, h1
, ul
, and li
elements with JSX
class names to style the component in the style.css
file.
Like its counterpart React, Vue is a progressive JavaScript framework built by Evan You in 2014 for building complex user interfaces. Vue focuses on the view portion of applications. It supports two-way data binding between the view and the model, especially considering the model-view-view-model (MVVM) framework.
import Vue from 'vue' import App from './App.vue' Vue.config.productionTip = false new Vue({ render: h => h(App), }).$mount('#app')
In the code above, Vue makes it easy to render data in our application onto the document. Also, looking at the main.js
file, we need to create an instance with the ID #app
to initialize a new app and keep track and manipulate the document.
In the App.vue
file, we import a HelloWorld
component that takes in a prop with a string of msg
, which parses the data and displays it as an expression in curly brackets {{msg}}
in the h1
element.