Can I get the role of the currentUser in modern WordPress React?

You can achieve this with the help of useSelect hook and select('core').getCurrentUser() here is the sample component for you.

import { useSelect } from '@wordpress/data';

const CurrentUserComponent = () => {
    const { currentUser } = useSelect((select) => ({
        currentUser: select('core').getCurrentUser(),
    }), []);

    // Here we are checking if currentUser is available or not.
    if (!currentUser) {
        return <p>Loading...</p>;
    }

    // Here we are accessing the roles.
    const roles = currentUser.roles || [];

    return (
        <div>
            <h2>Current User Roles:</h2>
            <ul>
                {roles.map(role => (
                    <li key={role}>{role}</li>
                ))}
            </ul>
        </div>
    );
};

export default CurrentUserComponent;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)