type DashboarWidgetContext = {
title: string
setTitle: string => void
widget: LiveWidgetEntity // the consolidated widget configuration
state: LiveDashboardWidgetState // LiveDashboardWidgetState
}
import React, { useContext } from 'react'
import { DashboardWidgetContext } from 'live/context/dashboard-widget'
export default () => {
const context = useContext(DashboardWidgetContext)
function updateTitle() {
context.setTitle(<span style={{color: 'red'}}>My title</span>)
}
return <a onClick={updateTitle}>change title</a>
}
declare type LiveDashboardWidgetState = {
params: {
spanFinal: string,
spanDetached: boolean,
span: string
}
state: {
loading: boolean,
receivedData: boolean,
started: boolean,
error?: {
remote: boolean
},
lastUpdate?: number,
lastEventTimestamp?: number,
layout: {
title: boolean,
timespan: boolean,
lastUpdate: boolean
}
}
widgetTransientParams?: LiveWidgetConfig
widget: LiveWidget
}