Cannot read property 'useEffect' of null

I’m having a strange issue on the server side when using React 18 and SSR. Sometimes, the application crashes with the following message:

TypeError: Cannot read property 'useEffect' of null
    at exports.useEffect (/var/app/current/bundle/programs/server/npm/node_modules/react/cjs/react.production.min.js:24:292)
    at StartComp (imports/ui/pages/start/start.js:79:5)

I’m importing React and the hooks like this:

import React, {useEffect, useState} from 'react';

On line 79, I have the following code:

    useEffect(() => {
        window.scrollTo(0, 0);
    }, [location.pathname]);

If I understand the message right, useEffect isn’t defined, which means is is not available from the imports. Does anyone have an idea how this could happen?