web-branch-deep-linking-attribution icon indicating copy to clipboard operation
web-branch-deep-linking-attribution copied to clipboard

Window is not defined error

Open rycustodio opened this issue 2 years ago • 3 comments

Describe the bug

I've added a listener and this error is showing.

Steps to reproduce

This is my code:

const [branchBanner, setBannerIsShowing] = useState(false);

  useEffect(() => {
    const initAndFetch = async () => {
      const branch = (await import('branch-sdk')).default;
      branch.closeJourney();
      branch.init(key);
      branch.track('pageview', { experiment: 'gen-banner' });

      branch.setBranchViewData({
        data: {
          x: 'open',
          y: id,
        },
      });

      branch.addListener(JourneyEvent.didShowJourney, () => {
        setBannerIsShowing(true);
      });

    };

    if (isMobile) {
      void initAndFetch();
    }
  }, [isMobile, id]);

Expected Behavior

There should be no error

Additional Information/Context

No response

SDK version used (window.branch.sdk)

2.58.2

Environment

chrome Version 110.0.5481.100

rycustodio avatar Feb 23 '23 01:02 rycustodio

+1

Mihai-github avatar Nov 03 '23 13:11 Mihai-github

Also experience this. Any idea ?

bogoroh avatar Dec 14 '23 02:12 bogoroh