Skip to content

Commit 61538c2

Browse files
author
Evan Jacobs
committed
fix: incorrect example code
1 parent 911cb72 commit 61538c2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sections/faqs/html-attribute-warnings.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ This will render:
3333
<a text="Click" href="https://www.styled-components.com/" red="true" class="[generated class]">Click</a>
3434
```
3535

36-
React will warn on non-standard attributes being attached such as "red" and "text", which are not valid HTML attributes for the `<a>` element.
36+
React will warn on non-standard attributes being attached such as "red" and "text", which are not valid HTML attributes for the `<a>` element.
3737

3838
To fix this, you can use transient props or destructure props:
3939

4040
### transient props (since 5.1)
4141

4242
You can use [transient props](https://styled-components.com/docs/api#transient-props) to fix this:
4343

44-
4544
```jsx
46-
const Link = ({ className, red, text, ...props }) => (
45+
const Link = ({ className, text, ...props }) => (
4746
<a {...props} className={className}>
4847
{text}
4948
</a>
@@ -77,9 +76,7 @@ const StyledComp = styled(Link)`
7776
This will render:
7877

7978
```html
80-
<a href="https://www.styled-components.com/" class="[generated class]">
81-
Click
82-
</a>
79+
<a href="https://www.styled-components.com/" class="[generated class]">Click</a>
8380
```
8481

8582
When you use argument destructuring, any variables pulled out of the props object will not be included when spread-applying the remaining props (`...props`);

0 commit comments

Comments
 (0)