0
votes

Hello I have a problem on how I will pass my props to a children:

interface RootState {
  sideIsOpen: boolean;
  isOpen: boolean;
}

const SideNavigation: React.FC = () => {
  // const { sideIsOpen } = useSelector((RootState) => RootState.toggleSide);
  const selectIsOpen = (state: RootState) => state.sideIsOpen;
  const sideIsOpen = useSelector(selectIsOpen);
  return (
    <SideNav>
      <LogoNavigation isOpen={sideIsOpen} />
    </SideNav>
  );
};

and my children:

const LogoNavigation: React.FC = (props) => {
  return (
    <LogoSide>
      <img src={Logo} alt="Logo Elo Ghost" />
    </LogoSide>
  );
};

i got this error:

Type '{ isOpen: boolean; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'. Property 'isOpen' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'.ts(2322)

2
Could you provide some info of LogoNavigation?keikai
Likely isOpen is not a property of LogoNavigation.Mario Vernari
i want pass isOpen to LogoNavigationFelipe

2 Answers

1
votes

You should to declare that yourLogoNavigation component expects to get isOpen.

You can do it with interface, it should be something like this: (It was'nt tested)

interface InterfaceName {
  isOpen: boolean
}

const LogoNavigation: React.FC<InterfaceName> = ({isOpen}) => {
  return (
    <LogoSide>
      <img src={Logo} alt="Logo Elo Ghost" />
    </LogoSide>
  )
}

Hope it helps.

0
votes

You need to declare LogoNavigation component so that it accepts isOpen prop. for that you can define a interface or do it like below

function LogoNavigation(props: { isOpen: boolean }) {

  return <div />;
}