Share this article:

Blog
Nov 04, 20224 min read

Varna and Burgas airports' websites use React components in Drupal

Varna and Burgas airports' websites use React components in Drupal

How did we end up needing React?

At Bulcode, we all ♥ Drupal, but when we first took over the support of the websites of Varna and Burgas airports, we inherited Drupal 8 systems that had been done in a way that wasn't so Drupal. As a result, the Drupal 9 migration / redevelopment was the first hurdle. For reference, you can see this article which explains the advantages of migration as well as the costs of doing nothing if you're still debating an upgrade (migration).

What makes it a challenge, exactly? Drupal 8 to Drupal 9 migration (or upgrade) is a mostly automated process, according to all sources of information. This is not always the case with most websites, especially when they are out of date with Drupal 8's most recent core and module contrib versions, so we at Bulcode always present it to clients as a small project of their own.

The inheritance we received for airport schedules was the driving force behind our decision to use React. A lot of manual work was required, as was the creation and upload of CSV files, which occasionally caused outages. It was a laborious process that occurred a few times a day. This was something that needed to be resolved as soon as possible.

So, what was our approach? With specific caching and React components for the frontend, API-driven schedules are fast and on-the-fly.

Why Drupal and React? Drupal is a content management system with a robust API for web services, and React is a simple way to build interactive user interfaces. The combination of React and Drupal works well in a number of ways. However, Drupal-powered sites can still make use of React for component development. This method is referred to as "progressive decoupling."

Now, let's see how it's put to use!

Adding React to our components: our experience

To begin, we must download and install all required dependencies:
yarn add react react-dom webpack webpack-cli @babel/cli @babel/core @babel/preset-env @babel/preset-react babel-loader webpack webpack-cli

Please note that we are not going to discuss the specifics of how each module works or which ones should be added as dev dependencies here. Using the packages page, you can see this.

Let's now set up our package.json scripts section:
package json scripts

Having separate dev and production webpack configurations is a good idea, so keep this in mind when creating your own files.

Add a simple webpack.config.js to the mix. React Hot Reloader with Webpack Server, some CSS, SASS, and file loaders, as well as additional plugins such as ESLint and minifiers are likely to be needed in your work. We won't go into this here because it's a matter of personal preference.

webpack config

Let's not forget our babel configs. This can be done using package.json or .babelrc.

babel config

We're getting closer and closer. In our dist folder, we'll find an app.bundle.js that we can use as a library in our theme when our build scripts are run. For ease of implementation, we'd like to add it to the entire app. Note that the performance of your application may be compromised if you only need React for a few components scattered across random pages.

app bundle js

We're ready to get started on our actual react component. The sky's the limit in this section.

src/index.jsx

react component

Finally, we'll add the markup required to display our React component. It's up to you now to put it where you want!

html

And voilà, we successfully integrated React into our Drupal project.

 

Fraport Bulgaria
”The individual approach, timely deliveries and precise documentation of the developments are a small part of the reasons for continuing the active partnership with Bulcode 2016 Ltd. It is our privilege and obligation to recommend the team of Bulcode 2016 Ltd. as extremely competent, reliable, and responsible in the implementation of the commitments.”

SUBSCRIBE TO OUR NEWSLETTER

Share this article:

SUBSCRIBE TO OUR NEWSLETTER

Related Blog Articles

    Building a high-performing Agile team: Our proven approach

    Blog

    Building a high-performing Agile team: Our proven approach

    Discover how we build high-performing Agile teams by defining clear roles, fostering collaboration, and using flexible tools.

    Written by Svetoslava Angelova
    Aug 27, 20248 min read
    Drupal 11: What to expect? Comprehensive guide to new features and enhancements

    Blog

    Drupal 11: What to expect? Comprehensive guide to new features and enhancements

    Drupal 11 is out! In this article, discover it's exciting features and improvements. Upgrade now to redefine your digital strategy with Bulcode's expert support.

    Written by Svetoslava Angelova
    Aug 05, 20247 min read
    Single Directory Components in Drupal core: A comprehensive overview

    Blog

    Single Directory Components in Drupal core: A comprehensive overview

    Explore how Single Directory Components (SDC) in Drupal Core streamline the development process by encapsulating component-related files into a single directory. Learn about the benefits of SDCs and follow a step-by-step guide to implement them in your Drupal projects.

    Written by Nikolay Tsekov
    Aug 07, 20244 min read
    Understand Drupal versions and plan a migration strategy

    Blog

    Understand Drupal versions and plan a migration strategy

    Recognise the various Drupal versions and keep your website up-to-date.

    Written by Svetoslava Angelova
    Mar 21, 20224 min read
    Drupal 9 convert image to WebP format

    Blog

    Drupal 9 convert image to WebP format

    WebP is able to take data compression to a new level thanks to the inclusion of a prediction mode to the JPG process, making it clear to see how it can outperform its JPG-based relative. And we have the results to prove it.

    Written by Vasil Boychev
    Apr 06, 20228 min read
    React overview - Definition, SPA, Components, Hooks

    Blog

    React overview - Definition, SPA, Components, Hooks

    React is a free and open-source front-end JavaScript framework for creating user interfaces based on UI components. It is also known as React.js or ReactJS.

    Written by Mihail Shahov
    May 13, 20226 min read
    What is Agile and why we use it?

    Blog

    What is Agile and why we use it?

    Agile is a time-boxed, iterative method to software delivery that aims to provide software gradually throughout the project rather than all at once near the end.

    Written by Svetoslava Angelova
    Sep 15, 20225 min read
    NVM vs NPM vs Yarn

    Blog

    NVM vs NPM vs Yarn

    Compared to the three technologies, NVM differs from the other two. Node Version Manager (NVM) is used to manage Node.js versions. NPM and Yarn are Node.js package managers. They allow downloading, installing, and managing packages when developing in JavaScript.

    Written by Ventsislav Venkov
    Sep 15, 20225 min read
    Which IT engagement model is right for you?

    Blog

    Which IT engagement model is right for you?

    Fixed price, time and materials, or dedicated teams? Consider carefully all the pros and cons of the engagement model for your project.

    Written by Svetoslava Angelova
    Sep 26, 202210 min read
    Laravel Mix - a simple and powerful wrapper around Webpack

    Blog

    Laravel Mix - a simple and powerful wrapper around Webpack

    Laravel Mix provides a fluent API for defining webpack build steps for your Laravel application using several common CSS and JavaScript pre-processors.

    Written by Stefani Tashkova
    Nov 15, 20224 min read
    What is Scrum?

    Blog

    What is Scrum?

    Scrum is a part of the Agile methodology. It is the most popular framework for agile development, and it is a simple process framework.

    Written by Svetoslava Angelova
    Nov 20, 20224 min read
    Roles in Scrum

    Blog

    Roles in Scrum

    Scrum roles and how you can fold them into your organisation.

    Written by Svetoslava Angelova
    Nov 21, 20224 min read

    GET IN TOUCH

    Have a project you'd like to launch?