Skip to content
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

prevent dollars to be passed to another function #71

Merged
merged 10 commits into from
Feb 21, 2024

Conversation

jantimon
Copy link
Collaborator

there was a bug which caused invalid prop forwarding

this pr adds the following test and ensures that it passes:

it("should filter out properties starting with $ when passing to custom", () => {
  let forwardedProps = null;
  const Component = ({ className, style, ...props}) => {
    forwardedProps = props;
    return null;
  };
  const StyledComponent = styled(Component)``;
  const { container } = render(<StyledComponent $forwardedProp="notForwarded" />);

  expect(forwardedProps).toEqual({});
});

@jantimon jantimon requested a review from Mad-Kat February 21, 2024 12:30
Copy link

vercel bot commented Feb 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
yacijs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2024 7:26pm

Copy link

codspeed-hq bot commented Feb 21, 2024

CodSpeed Performance Report

Merging #71 will improve performances by 23.57%

Comparing feature/remove-dollars (3c2388d) with main (1844d86)

Summary

⚡ 1 improvements
✅ 1 untouched benchmarks

Benchmarks breakdown

Benchmark main feature/remove-dollars Change
render KanjiLetterComponentYak 295.4 ms 239.1 ms +23.57%

rvetere
rvetere previously approved these changes Feb 21, 2024
Copy link
Collaborator

@rvetere rvetere left a comment

Choose a reason for hiding this comment

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

looks good to me

Copy link
Collaborator

@Mad-Kat Mad-Kat left a comment

Choose a reason for hiding this comment

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

Generally the change looks good and I don't know where the -24% execution time comes in, but I like it 😄

I think the approach of not forwarding the props if it's not a yak-component is generally good, but we have to think about the case with the theme.

What do you think?

packages/next-yak/runtime/__tests__/styled.test.tsx Outdated Show resolved Hide resolved
packages/next-yak/runtime/__tests__/attrs.test.tsx Outdated Show resolved Hide resolved
packages/next-yak/runtime/__tests__/styled.test.tsx Outdated Show resolved Hide resolved
@jantimon
Copy link
Collaborator Author

Generally the change looks good and I don't know where the -24% execution time comes in, but I like it 😄

I think the approach of not forwarding the props if it's not a yak-component is generally good, but we have to think about the case with the theme.

What do you think?

Maybe I found a fix - lets see if the pipeline is happy

@jantimon
Copy link
Collaborator Author

The performance gain is that it now finally detects nested yak components and calls them directly without telling react 🤣

Copy link
Collaborator

@Mad-Kat Mad-Kat left a comment

Choose a reason for hiding this comment

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

Good job. Really nice change

@jantimon jantimon merged commit 91133d9 into main Feb 21, 2024
6 checks passed
@jantimon jantimon deleted the feature/remove-dollars branch February 23, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants