Skip to content

feat(proposal): memoized children list, refactored code #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mykola-kolomoyets
Copy link

No description provided.


if (isChildTrue === true && list.length < limit) {
list.push(child);
if (childCondition && list.length < limit) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on this line (col 31) throws a ts error

'list' is possibly 'null' or 'undefined'.`


RenderWhen.If = ({ children, isTrue }) => children;
const If: React.FC<WhenProps> = memo(({ children }) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on this line, (col 41) throws this error

  Overload 1 of 2, '(Component: FunctionComponent<{ condition?: boolean | undefined; limit?: number | undefined; } & { children?: ReactNode; }>, propsAreEqual?: ((prevProps: Readonly<{ condition?: boolean | undefined; limit?: number | undefined; } & { ...; }>, nextProps: Readonly<...>) => boolean) | undefined): NamedExoticComponent<...>', gave the following error.
    Argument of type '({ children }: { condition?: boolean | undefined; limit?: number | undefined; } & { children?: ReactNode; }) => ReactNode' is not assignable to parameter of type 'FunctionComponent<{ condition?: boolean | undefined; limit?: number | undefined; } & { children?: ReactNode; }>'.
      Type 'ReactNode' is not assignable to type 'ReactElement<any, any> | null'.
        Type 'undefined' is not assignable to type 'ReactElement<any, any> | null'.
  Overload 2 of 2, '(Component: ComponentType<any>, propsAreEqual?: ((prevProps: Readonly<any>, nextProps: Readonly<any>) => boolean) | undefined): MemoExoticComponent<ComponentType<any>>', gave the following error.
    Argument of type '({ children }: { condition?: boolean | undefined; limit?: number | undefined; } & { children?: ReactNode; }) => ReactNode' is not assignable to parameter of type 'ComponentType<any>'.
      Type '({ children }: { condition?: boolean | undefined; limit?: number | undefined; } & { children?: ReactNode; }) => ReactNode' is not assignable to type 'FunctionComponent<any>'.
        Type 'ReactNode' is not assignable to type 'ReactElement<any, any> | null'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants