How to add value to the props

2 posts, 0 answers
  1. Ofer
    Ofer avatar
    28 posts
    Member since:
    Jul 2019

    Posted 27 Feb 2020 Link to this post

    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


  2. Kiril
    Kiril avatar
    24 posts

    Posted 28 Feb 2020 Link to this post

    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.

    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.

    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
Back to Top