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

Pass through component types when using withSitecoreContext #214

Merged
merged 1 commit into from Jul 16, 2019

Conversation

@davetayls
Copy link
Contributor

@davetayls davetayls commented Jul 16, 2019

Description

This takes the props type from the original component and uses it to form the prop types for the HOC.

Motivation

The component prop types were getting lost when wrapped in withSitecoreContext

How Has This Been Tested?

npm run test-packages

I've also packed the package and pulled it into our repo and built it successfully.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the Contributing guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
kamsar
kamsar approved these changes Jul 16, 2019
@kamsar kamsar merged commit 982d09b into Sitecore:dev Jul 16, 2019
1 check passed
Loading
@davetayls davetayls deleted the with-sitecore-context-hoc-types branch Jul 17, 2019
@davetayls
Copy link
Contributor Author

@davetayls davetayls commented Jul 17, 2019

Thanks @kamsar - I notice that the last release of these packages was 6 months ago. Are you able to do a new release with these updates so that we can use them in our sitecore build?

Loading

@peterswallow
Copy link

@peterswallow peterswallow commented Sep 23, 2020

@davetayls
I'm getting this error

[17:18:24][Step 1/5] Argument of type 'FunctionComponent<ProductProps>' is not assignable to parameter of type 'ComponentType<ComponentConsumerProps>'.
[17:18:24][Step 1/5]   Type 'FunctionComponent<ProductProps>' is not assignable to type 'FunctionComponent<ComponentConsumerProps>'.
[17:18:24][Step 1/5]     Types of parameters 'props' and 'props' are incompatible.
[17:18:24][Step 1/5]       Type 'PropsWithChildren<ComponentConsumerProps>' is not assignable to type 'PropsWithChildren<ProductProps>'.
[17:18:24][Step 1/5]         Type 'PropsWithChildren<ComponentConsumerProps>' is missing the following properties from type '{ fields: ProductFields; iframeAttributes: IFrameProps; }': fields, iframeAttributes  TS2345
[17:18:24][Step 1/5] 
[17:18:24][Step 1/5]     122 | };
[17:18:24][Step 1/5]     123 | 
[17:18:24][Step 1/5]   > 124 | export const Product = withSitecoreContext()(ProductComponent);
[17:18:24][Step 1/5]         |                                              ^
[17:18:24][Step 1/5]     125 |

on the last line of this

const ProductComponent: FunctionComponent<ProductProps> = ({
   ...
}

export const CarRentalUpsell = withSitecoreContext()(ProductComponent);
                                                     ^

Could the above change be causing this error?

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants