fp-ts. How can I do recursion in an array and make the isShow flag true?

61 views Asked by At

I have an array nested within an array. What is the correct way to write a recursive function? I'm just new to using the library fp-ts

I wrote a function. Which makes the flag isShow true.

Link to example https://stackblitz.com/edit/typescript-39acrw?file=index.ts

import {pipe} from 'fp-ts/function';
import * as A from 'fp-ts/Array';
import * as S from 'fp-ts/Separated';

const getSidebar = ({ menu, isAbility }: IgetSidebar) =>
  pipe(
    menu,
    A.map((el) => ({
      ...el,
      children: pipe(
        el.children,
        A.partition((children) => {
          if (children.key === 'children22') {
            return (children.isActive = isAbility);
          }

          return children.isActive;
        }),
        S.right
      ),
    }))
  );


  getSidebar({
    menu: menus,
    isAbility: true,
  })

0

There are 0 answers