I am trying to use https://gcanti.github.io/fp-ts/modules/Option.ts.html as follows:
import O, {Option} from "fp-ts/Option";
....
useEffect(() => {
if (error) {
handleResultCategories(O.none);
return;
}
handleResultCategories(O.some(selection));
}, [error, selection]);
....
the compiler complains:
TypeError: Cannot read property 'some' of undefined
at http://localhost:6006/main.22489267b0e89682c1e1.hot-update.js:130:82
at invokePassiveEffectCreate
Changing to:
....
import {Option, some, none} from "fp-ts/Option";
useEffect(() => {
if (error) {
handleResultCategories(none);
return;
}
handleResultCategories(some(selection));
}, [error, selection]);
....
it works. What is wrong with the first approach?