Skip to content

Commit

Permalink
Update v6 migration guide for shouldForwardProp (#939)
Browse files Browse the repository at this point in the history
* fix: update broken link

* docs: more detailed code example for v6 prop forwarding migration

* fix: update code indentation to match existing style

---------

Co-authored-by: Ben Cole <[email protected]>
  • Loading branch information
bcole808 and Ben Cole authored Oct 14, 2023
1 parent be1309b commit ebe1729
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sections/faqs/migration-v6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@ import { StyleSheetManager } from 'styled-components';

function MyApp() {
return (
<StyleSheetManager shouldForwardProp={isPropValid}>
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
{/* other providers or your application's JSX */}
</StyleSheetManager>
)
}

// This implements the default behavior from styled-components v5
function shouldForwardProp(propName, target) {
if (typeof target === "string") {
// For HTML elements, forward the prop if it is a valid HTML attribute
return isPropValid(propName);
}
// For other elements, forward all props
return true;
}
```

### Vendor prefixes are omitted by default
Expand Down

0 comments on commit ebe1729

Please sign in to comment.