Unexpected outcome when updating parameters with API

Hello, just trying to play around with updating parameters using an API on some existing public model.

I created a test next.js project following this React setup example

Trying to update the parameter using documentation from here

session.parameters["parameterId"].value = newValue;
await session.customitze();

here’s the piece of code that does it:

But I get some unexpected outcome. This is what I get when I change the width from 2000 to 1000 on ShapeDiver portal:

And this is what I get when doing it with an API. Seems like 2 objects have merged:

This is my repo in case it helps

Is there something I’m missing? Also, will there be more react js examples in the help center? Most examples seem to use typescript

Hello @Sebastian_Meckovski

I updated the codesandbox to your repo and there it seems to work: react setup - adapted (forked) - CodeSandbox

My assumption is that the function where a session is created is called multiple times. You could just add a flag there and return the session that was created the first time.

The same may also happen to the viewport creation.

Hope this helps!

Cheers, Michael

Thanks for pointing that out! getSession() function was indeed running twice. I appears that React introduced some weird behaviour recently

Basically when running in development mode it executes useEffect twice, not exactly sure why, but I switched to production env and it’s now working fine.

Great, glad this is resolved.

@Tim_Thimmaiah your issue could be related to this!