Finding Nearest Error Boundary in a More Effect-ish Way

is there a more Effect-ish way to write
function findNearestErrorBoundary(fiber: Fiber): Option.Option<Fiber> {
  let current: Option.Option<Fiber> = Option.some(fiber);
  while (Option.isSome(current)) {
    const f = current.value;
    if (Option.isSome(f.errorBoundary)) return Option.some(f);
    current = f.parent;
  }
  return Option.none<Fiber>();
};
Was this page helpful?