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

Sweep: Normalize components declarations to export default named functions #1

Open
2 tasks done
0xGeegZ opened this issue Sep 19, 2023 · 1 comment
Open
2 tasks done
Labels

Comments

@0xGeegZ
Copy link
Owner

0xGeegZ commented Sep 19, 2023

Description

We need to standardize the way we define React functional components in our codebase. Currently, we have a mix of two different patterns, and we want to stick to one for consistency.

⚠️ Warning ⚠️

  • Only update React functional components. Do not change class components or utility functions.
  • Only update the exported function of the component. Internal functions should remain unchanged.

Current Pattern

Files are currently using this pattern:

export default function ComponentName() {
  ...
}

Desired Pattern

We want all files to use this pattern:

const ComponentName = (props: any) => {
  ...
}
export default ComponentName;

Task

  • Find all instances of the old pattern in the codebase.
  • Update them to the new pattern.

Acceptance Criteria

  • All React functional components should be defined using the new pattern.
  • The application should build and run without errors after the changes.

Warning : Update ONLY code to follow this request, DO NOT update anything else and DO NOT add comments .

Checklist
  • components/magicui/tweet-card.tsx ✅ Commit 29e0820
• Replace the old pattern `export default function ComponentName()` with the new pattern `const ComponentName = (props: any) => {}` and add `export default ComponentName;` at the end of the component for `MyTweet`, `TweetCard`, and `ServerTweetCard`.
  • components/landing/examples/examples.tsx ❌ Failed
• This file does not seem to contain any React functional components based on the provided snippet. Therefore, no changes are required.
@0xGeegZ 0xGeegZ changed the title Normalize components declarations to export default named functions Sweep: Normalize components declarations to export default named functions Sep 19, 2023
@0xGeegZ 0xGeegZ added the sweep label Sep 19, 2023
Repository owner deleted a comment from sweep-0xgeegz bot Sep 23, 2023
@sweep-0xgeegz
Copy link

sweep-0xgeegz bot commented Sep 23, 2023

Here's the PR! #6.

💎 Sweep Pro: I'm creating this ticket using GPT-4. You have unlimited GPT-4 tickets.

Actions (click)

  • ↻ Restart Sweep

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

target="_blank"
rel="noopener noreferrer"
className="text-muted-foreground"
>
<span>{entity.text}</span>
</a>
)
case "text":
return (
<span
key={idx}
className="text-sm"
dangerouslySetInnerHTML={{ __html: entity.text }}
/>
)
}
})}
</div>
)
type Props = {
tweet: Tweet
components?: TwitterComponents
className?: string
}
export const MyTweet = ({
tweet: t,
components,
className,
...props
}: Props) => {
const tweet = enrichTweet(t)
return (
<div
className={cn(
"relative flex h-32 max-h-max w-full flex-col gap-2 overflow-hidden rounded-lg border p-4 backdrop-blur-md",
className
)}
{...props}
>
<TweetHeader tweet={tweet} />
<TweetBody tweet={tweet} />
<div className="flex flex-1 justify-center items-center">
{tweet.video && (
<video
poster={tweet.video.poster}
src={tweet.video.variants[0].src}
autoPlay
loop
muted
className="rounded-xl border shadow-sm"
/>
)}
{tweet.photos && (
<div className="flex flex-row gap-2">
{tweet.photos.map((photo) => (
<img
key={photo.url}
src={photo.url}
className="rounded-xl border shadow-sm"
/>
))}
</div>
)}
</div>
</div>
)
}
export const TweetCard = ({
id,
apiUrl,
fallback = <TweetSkeleton />,
components,
onError,
...props
}: TweetProps & { className?: string }) => {
const { data, error, isLoading } = useTweet(id, apiUrl)
if (isLoading) return fallback
if (error || !data) {
const NotFound = components?.TweetNotFound || TweetNotFound
return <NotFound error={onError ? onError(error) : error} />
}
return <MyTweet tweet={data} components={components} {...props} />
}
export const ServerTweetCard = ({
tweet,
...props
}: {
tweet: any
[key: string]: any
}) => {
return <MyTweet tweet={tweet} {...props} />
}

},
{
full_name: "Morty Smith",
age: "14",
about:
"Morty is Rick's good-hearted but easily distressed grandson who is frequently dragged into Rick's misadventures.",
},
{
full_name: "Jerry Smith",
age: "34",
about:
"Jerry is Morty's insecure father who dislikes Rick's influence over his family.",
},
{
full_name: "Summer Smith",
age: "17",
about:
"Summer is Morty's somewhat rebellious teenage sister who occasionally joins Rick on his adventures.",
},
{
full_name: "Beth Smith",
age: "34",
about:
"Beth is Morty's assertive mother and Rick's daughter. She is a horse surgeon.",
},
],
},
randomNews: {
prompt: "Generate random news about sport topic",
limit: 5,
fields: [
{
name: "title",
inputType: "string",
description: "title of the news",
},
{
name: "published_date",
inputType: "string",
description:
"Publish date of the news, it should be anytime in this week",
},
{
name: "short_description",
inputType: "number",
description: "short description about the news",
},
{
name: "description",
inputType: "string",
description:
"long description about the news, just write a few paragraphs. 1000 character at maximum.",
},
],
output: [
{
title: "Grand Slam Victory for Serena Williams",
published_date: "November 3, 2021",
short_description:
"Tennis superstar Serena Williams triumphed in the Grand Slam, marking her 24th major victory.",
description:
"Progressing through the tournament with outstanding performances, Serena Williams has secured a Grand Slam victory once again. Williams, who has a reputation for resilience and power, did not falter under the pressure of the challenging matches. This win takes her total major victories to 24, equaling the record held by Margaret Court. Williams' performance throughout the tournament was exemplary, demonstrating her skill, strategy, and unmatchable baseline powers.",
},
{
title: "Lewis Hamilton Clinches Victory in Monza",
published_date: "November 4, 2021",
short_description:
"In a dramatic twist, Lewis Hamilton wins the Italian Grand Prix, inching closer to his seventh World Championship title.",
description:
"Lewis Hamilton delivered a masterful driving performance at Monza to win the Italian Grand Prix. It was a race filled with intense battles, strategic plays and a thrilling finish that saw Hamilton beat out his closest rivals. With this win, Hamilton is edging closer to his record-tying seventh World Championship title.",
},
{
title: "Lakers Take Dominant Win Over Golden State",
published_date: "November 5, 2021",
short_description:
"The Lakers take a commanding victory over Golden State Warriors, showcasing their exceptional team performance.",
description:
"The Lakers have once again proven their dominance on the court with an outstanding victory over the Golden State Warriors. Showcasing a remarkable team performance, the Lakers managed to control the game from the outset, with every player contributing to the team's win. Their aggressive defense and seamless transitions led to this impressive victory.",
},
{
title: "Sidney Crosby Strikes Hat-Trick in NHL Game",
published_date: "November 6, 2021",
short_description:
"Penguins star Sidney Crosby scored an amazing three-goal hat-trick in Pittsburgh's game against Philadelphia.",
description:
"Ice Hockey all-star Sidney Crosby was the star of the show in Pittsburgh Penguins' game against Philadelphia Flyers, scoring an amazing three-goal hat-trick. His skills were on full display throughout the match, showing why he's considered one of the best players in the league. This hat-trick is a testament to Crosby's talent and a treat for Penguins' fans.",
},
{
title: "Usain Bolt Returns to Athletics",
published_date: "November 7, 2021",
short_description:
"Sprinter Usain Bolt declares his return to competitive athletics,",
},
],
},
musicGenres: {
prompt: "Music genres",
limit: 20,
fields: [
{
name: "title",
inputType: "string",
description: "Name of the genre",
},
],
output: [
{ title: "Pop" },
{ title: "Rock" },
{ title: "Rap" },
{ title: "Classical" },
{ title: "Jazz" },


Step 2: ⌨️ Coding

  • components/magicui/tweet-card.tsx ✅ Commit 29e0820
• Replace the old pattern `export default function ComponentName()` with the new pattern `const ComponentName = (props: any) => {}` and add `export default ComponentName;` at the end of the component for `MyTweet`, `TweetCard`, and `ServerTweetCard`.
  • components/landing/examples/examples.tsx ❌ Failed
• This file does not seem to contain any React functional components based on the provided snippet. Therefore, no changes are required.

Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/normalize-component-declarations_2.

.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord

Repository owner deleted a comment from sweep-ai bot Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment