Skip to content

Commit 3783df3

Browse files
committed
fix: update text fixtures
1 parent 4e19fb5 commit 3783df3

6 files changed

Lines changed: 21 additions & 6 deletions

File tree

codemods/react/19/replace-default-props/__testfixtures__/button-jsx-example-input.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ const Button = ({ size, color }) => {
55
Button.defaultProps = {
66
size: "16px",
77
color: "blue",
8-
};
8+
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const Button = ({ size = "16px", color = "blue" }) => {
22
return <button style={{ color, fontSize: size }}>Click me</button>;
3-
};
3+
};

codemods/react/19/replace-default-props/__testfixtures__/nested-destructuring.output.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const Card = ({ user: { name, age } = {
1+
const cardDefaultPropUser = {
22
name: "Unknown",
33
age: 0,
4-
} }) => {
4+
};
5+
6+
const Card = ({ user: { name, age } = cardDefaultPropUser }) => {
57
return (
68
<div>
79
<p>{name}</p>
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const C = (props) => {
2+
console.log(props.helloWorld);
23
return <>{props.text}</>;
34
};
45

56
C.defaultProps = {
6-
text: "test",
7+
text: "Hello",
8+
test: 2,
9+
helloWorld: true,
710
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
const C = (props) => {
2+
props = {
3+
...props,
4+
text: typeof props.text === "undefined" ? "Hello" : props.text,
5+
test: typeof props.test === "undefined" ? 2 : props.test,
6+
helloWorld: typeof props.helloWorld === "undefined" ? true : props.helloWorld
7+
};
8+
9+
console.log(props.helloWorld);
210
return <>{props.text}</>;
311
};
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
const List = ({ items = [], renderItem = (item) => <li key={item}>{item}</li> }) => {
1+
const listDefaultPropItems = [];
2+
const listDefaultPropRenderItem = (item) => <li key={item}>{item}</li>;
3+
const List = ({ items = listDefaultPropItems, renderItem = listDefaultPropRenderItem }) => {
24
return <ul>{items.map(renderItem)}</ul>;
35
};

0 commit comments

Comments
 (0)