Mikael G
Mikael G

Reputation: 33

Pass custom properties in Resource in V4

Bit of a newbie here that recently moved to v4. I have some Resources declared using options to pass some custom property. In React Admin 3 syntax:

<Resource name='mydata' options={{label: "Mylabel", site: site}} list={MyList} />

This is using the options prop to pass down my site property. Since the props injection is removed in React admin V4 - what is a good way to pass this prop to my list component in V4?

Upvotes: 0

Views: 684

Answers (1)

WiXSL
WiXSL

Reputation: 707

You can still pass the options prop to the Resource component.

And you can get it like this:

const PostList = () => {
    const { options } = useResourceDefinitions();
    // ... 
}

This is somewhat explained in the Upgrade Guide from v3 to v4:

https://marmelab.com/react-admin/Upgrade.html#custom-menus-should-get-resource-definition-from-context

Upvotes: 1

Related Questions