Hello!
Can someone tell me how to get the Client inside the React app with using FDK version 9 ?
The old way used to work in this way :
Regards,
Nasir
Hello!
Can someone tell me how to get the Client inside the React app with using FDK version 9 ?
The old way used to work in this way :
Regards,
Nasir
Hi @Nasir_Haidari ,
You can use something like this:
const App = () => {
const [loaded, setLoaded] = useState(false);
const [child, setChild] = useState(<h3>App is loading</h3>)
useLayoutEffect(() => {
const script = document.createElement('script');
script.src = '{{{appclient}}}';
script.addEventListener('load', () => setLoaded(true));
script.defer = true;
document.head.appendChild(script);
}, []);
useLayoutEffect(() => {
if (!loaded) return
app.initialized().then((client) => {
setChild((<HelloUser client={client} />))
})
}, [loaded])
return (
<div>
{child}
</div>
)
}
Please let us know if you face any issues.
Also, note the use of useLayoutEffect
instead of useEffect
.
Thanks!
This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.