How can I make an API call (possibly async) to fetch data to be able to use it further. The class does not render anything by itself.
I am new to functional components and am trying to - fetch data in AppForm and - send it over as an argument to fun2().
Any suggestions are greatly appreciated. Code snippets would be even more helpful. Thanks in advance.
const AppForm = ({ x, y, z, id, ...props }) => (
<InnerForm
input={x ? fun1(x) : fun2()}
isEqual={(a, b) => (a && a.id) === (b && b.id)}
>
{val => (
<MainForm
x={x}
y={y}
z={z}
initialValues={val}
{...props}
/>
)}
</InnerForm>
);
AppForm.propTypes = {
x: PropTypes.object,
y: PropTypes.object,
z: PropTypes.object,
}