Next.js Discord

Discord Forum

Passing props into my useEffect for a script

Unanswered
Jimdog posted this in #help-forum
Open in Discord
I cannot seem to get my site plan data (which is being pass through as props) to be recognised by my initialisation statement for a plugin I am using.

data.sitePlan is equal to an object. The second image is data.sitePlan but hardcoded.

Does anyone know how I can get this to work? The frontend shows a blank block with that parameter but when it is hardcoded it's fine.

Ideally, i'd like to be able to inspect the output of this but i'm unsure how.

7 Replies

Asian black bear
An issue that you might be running into is that the identity of data needs to change to cause for the component to re-render.
So you need to handle it reducer style like setData({...data,sitePlan:{...}})
Sort of similar to this?

window.ImageMapPro.init(containerRef.current, { ...data.sitePlan });

TY
Asian black bear
no, not exactly
when you do <ImageMapPro data={data}/>
it does not know if you change a member of data, it must be a new object
Thank you