New in 1.34.0 (BETA)

useDataItem(dataClassName)

Returns the closest DataItem from the current data.

Current data is mostly set automatically by the SDK, based on the particular structure and DataLocators of the content in question, but it can also be provided using the Scrivito.ContentTag component with a dataContext prop.

Params

[New in 1.44.0 (BETA)]dataClassName (String) – Optional data class name. If the class name is specified, the current data is searched for the first DataItem with the given class name. If no such DataItem can be found in the current data, the global data (provided via provideDataItem) is searched.

Returns

DataItem or undefined – The closest DataItem from the current data. If no current data is available or if the current data contains no data items (i.e., only data scopes), undefined is returned.

If the class name is given, the current data is searched for the first DataItem with the given class name. If no such DataItem can be found in the current data, a matching global DataItem (via provideDataItem) is returned if it exists. Otherwise undefined is returned.