New in 1.41.0 (BETA)

useData()

Returns a DataScope from the current data.

Returns

DataScope – A DataScope 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.

If there is no current data available, then an empty scope is returned.

useData never returns the object data of the current page and its ancestors. You can access this data via the page or widget component’s props, or by calling useDataItem with the class name.

Note that the returned DataScope can be a single-item scope. In order to check if a DataScope is a single-item scope, DataScope#isDataItem is available: