This is a migrated thread and some comments may be shown as answers.

How to add value to the props

1 Answer 149 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ofer
Top achievements
Rank 1
Veteran
Ofer asked on 27 Feb 2020, 01:30 PM

I am working in SPFx web part so everything is typescript

I have a Grid that uses a child component for detail

<Grid data={items} detail={ DetailDocumentsComponent } 

So the props on the component is GridDetailRowProps  

export function DetailDocumentsComponent(props: GridDetailRowProps) {

I also want to past the context of where the grid is, to the child component. how can I do it?

Is there an option to 2 parameters?

can I overload the GridDetailRowProps type to have context:any ? how would I do it?

Thank you

 

1 Answer, 1 is accepted

Sort by
0
Kiril
Telerik team
answered on 28 Feb 2020, 07:56 AM

Hello Ofer,

In make some value from the parent accessible to all children without explicitly passing it as a prop, i can suggest the usage of the React Context API.

I have prepared the following stackblitz example demonstrating a generic usage of the Context API with the KendoReact Grid `detail` property.

https://stackblitz.com/edit/react-1en72t

In order for me to provide a more detailed solution to your issue, may i ask you to send the full code of your component?

Please let me know if this solves your problem or if i have misunderstood your problem, and i will be happy to help.

Regards,
Kiril
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Ofer
Top achievements
Rank 1
Veteran
Answers by
Kiril
Telerik team
Share this question
or