Jump to content
RAGE Multiplayer Community

ExecuteJs cannot find ReactJs function


Recommended Posts

Hello,

 

I've been facing a problem while using ExecuteJs() with a ReactJs application.

I'm getting this error in cef_game_logs.txt:

[0131/163336.765:INFO:CONSOLE(1)] "Uncaught ReferenceError: handleWrongPassword is not defined", source:  (1)

Is everything fine in my ClientSide code aswell as in ServerSide?
ClientSide code:

// In Main class:   
public Main() 
{
   Browser.Create();
   Events.Add("WrongPassword", ShowWrongPassword);
   // other events
}
private void ShowWrongPassword(object[] args)
{
   bool isWrong = (bool)args[0];
   Browser.ExecuteJs("handleWrongPassword",isWrong.ToString());
}

// In Browser class:
public static void ExecuteJs(string functionName, [Optional] string formattedArgs)
{
   Cef.ExecuteJs($"{functionName}({formattedArgs})");
}

ServerSide code:

NAPI.ClientEventThreadSafe.TriggerClientEvent(player, "WrongPassword", true);

ReactJs code:

const Login = () => {
  const [isWrongPassword, setIsWrongPassword] = useState(false);
  const handleWrongPassword = (isWrong: boolean) => {
    setIsWrongPassword(isWrong);
  };
  ...
  return // some components
}

 

Edited by WaspNetwork
Link to post
Share on other sites
  • WaspNetwork changed the title to ExecuteJs cannot find ReactJs function

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...