How to load Redux conditionally in a component?

One of my component is in Git submodule, and loaded in a React app, and in different WordPress shortcodes also.

React components can communicate via Redux, but WordPress shortcodes not. Shortcodes can communicate with Javascipt events.

How can I load followings conditionally, not load into a shortcode, but load event notification?

import { setGetUser } from "../../slices/User";
import { RootStateOrAny, useDispatch, useSelector } from "react-redux";

function LoginAndRegistration(props: LoginAndRegistrationProps) {
  const completion = (getUserOut: GetUserOut) => {
    dispatch(setGetUser(getUserOut));