Using React, I have the following functional component where I make use of useEffect():
import React, { useEffect } from \'react\';
import { con
If I understand correctly, you want to mimic the "on component mounted" behaviour of regular class based react components via useEffect(), so that the effect callback only fires once on the first render.
To achieve that behaviour, you can pass an empty array to the second argument of useEffect() like so:
useEffect(() => {
loadMessages();
}, []); /* <-- add this */
The second array argument allows you to specify which prop variables trigger the userEffect() callback (if any) when their value(s) change.
By passing an empty array, this means that useEffect() won't be triggered by any changes to input prop variables and will in turn only ever be called once, during the first render.
For more information on this second argument, see this documentation and this documentation