Photon Realtime + React?

Options
Hello! Apologies if this has been answered before but the docs seem pretty sparse and I searched the forum and haven't found an answer.

I'm trying to add Photon to my ReactJS app. Currently I'm doing the following:
import "./Photon/Photon-Javascript_SDK.js";
import React, { createContext, useEffect, useState } from 'react';

const App = () => {

  useEffect(() => {
      var client = Photon.LoadBalancing.LoadBalancingClient);
  }, []) 



(Removed some code of course.) But I'm getting this error:
'Photon' is not defined  no-undef
I've tried about a million ways of including the sdk. Anybody know what I might be doing wrong?

Comments

  • vadim
    Options
    Hi,
    Photon lib is just a js code, you need to run it somehow, then Photon object will appear in global namespace. Not sure if 'import' executes something. Can you try simple <script src=.../> in html?