  Heavy-flavour quarks, due to their large masses, are produced in the early
stages of the relativistic heavy-ion collisions via initial hard scatterings.
Therefore, as they experience the full system evolution, heavy quarks are
effective probes of the hot and dense medium created in such collisions. In pp
collisions, the measurement of heavy-flavour hadron production cross sections
can be used to test our understanding of the Quantum ChromoDynamics (QCD) in
the perturbative regime. Also, pp collisions provide a crucial reference for
the corresponding measurements in larger systems. In Pb--Pb (Xe--Xe)
collisions, the measurement of the nuclear modification factor of heavy-flavour
hadrons provides information on the modification of the invariant yield with
respect to pp collisions due to the produced cold and hot QCD matter. The
possible mass dependence of the parton energy loss can be studied by comparing
the $R_{\rm AA}$ of pions, charm and beauty hadrons. In this contribution,
recent results from ALICE at the LHC are reported with focus on the different
measurements of the heavy-flavour electrons in pp collisions at 2.76, 5.02, 7
and 13 TeV and in Pb--Pb (Xe--Xe) collisions at 5.02 (5.44) TeV. The results
include the differential production cross sections and nuclear modification
factors of heavy-flavour electrons at mid-rapidity. The comparison of
experimental data with model predictions is discussed.
