diff --git a/packages/react-jsx-highcharts/src/components/PlotBandLine/PlotBandLineLabel.js b/packages/react-jsx-highcharts/src/components/PlotBandLine/PlotBandLineLabel.js index 4ab26e34..2061e924 100644 --- a/packages/react-jsx-highcharts/src/components/PlotBandLine/PlotBandLineLabel.js +++ b/packages/react-jsx-highcharts/src/components/PlotBandLine/PlotBandLineLabel.js @@ -3,11 +3,12 @@ import { attempt } from 'lodash-es'; import usePlotBandLine from './UsePlotBandLine'; const PlotBandLineLabel = memo(props => { - const { object: plotbandline } = usePlotBandLine(); + const providedPlotbandline = usePlotBandLine(); useEffect(() => { + if (!providedPlotbandline) return; const { children: text, id, ...rest } = props; - updatePlotBandLineLabel(plotbandline, { + updatePlotBandLineLabel(providedPlotbandline.object, { text, ...rest }); @@ -15,11 +16,12 @@ const PlotBandLineLabel = memo(props => { useEffect(() => { return () => { - attempt(updatePlotBandLineLabel, plotbandline, { + if (!providedPlotbandline) return; + attempt(updatePlotBandLineLabel, providedPlotbandline.object, { text: null }); }; - }, [plotbandline]); + }, [providedPlotbandline]); return null; }); diff --git a/packages/react-jsx-highcharts/src/components/PlotBandLine/UsePlotBandLineLifecycle.js b/packages/react-jsx-highcharts/src/components/PlotBandLine/UsePlotBandLineLifecycle.js index fdabc7c4..7685594a 100644 --- a/packages/react-jsx-highcharts/src/components/PlotBandLine/UsePlotBandLineLifecycle.js +++ b/packages/react-jsx-highcharts/src/components/PlotBandLine/UsePlotBandLineLifecycle.js @@ -4,10 +4,10 @@ import { attempt } from 'lodash-es'; import useModifiedProps from '../UseModifiedProps'; import useAxis from '../UseAxis'; -export default function usePlotBandLine(props, plotType) { - const { id = uuid, children, ...rest } = props; +export default function usePlotBandLineLifecycle(props, plotType) { + const { id = uuid, axisId, children, ...rest } = props; - const axis = useAxis(); + const axis = useAxis(axisId); const idRef = useRef(); const [plotbandline, setPlotbandline] = useState(null); const modifiedProps = useModifiedProps(rest);