So I have a Page component that contains several Column components, each column contains different user-specific markup.
In the Page component I need to do some additional mutations (like the column overflow check, pushing columns content around, etc.). For this reason, I need a way to be notified after all Column components have mounted - also including implicit mutations have been made.
My first attempt was useEffect hook, however, it does get called before the Column component even receives it's ref.
// AppContext
const [columns, setColumns] = useState([]);
const Page = ({children}) => {
useEffect({
// This gets called before columns are available
}, []);
return (<div className="page">{children}</div>);
}
const View = () => {
const {columns} = useContext(AppContext);
return (
<Page>
{columns.map(c => <Column>{c}</Column>)}
</Page>
);
}