Is there way to get context in usual Javascript function (in function which is not being rendered)?
I have function which doesn't render anything (it downloads .csv) which uses hook (using hook is not correct solution)
const archiveExportCSV=async(tasks)=> {
let context = useContext(StaticsContext);
//... some code which uses context
Helpers.download(csv,'test.csv','data:text/csv;charset=utf-8');
};
and I am calling it in component:
<button type="button"
className="btn-reset"
title="export to .csv"
onClick={()=>archiveExportCSV(tasks)}>
It is wrong because function is neither a React function component or a custom React Hook function. Is there any way how get context in callable function or I have to pass arguments from context manually as arguments?
archiveExportCSV(tasks, somethingFromContext)right?