Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

javascript - How to fix the 'setOption' does not exist on type 'MutableRefObject in react

CODE

export default function EChart({ option, config, resize }) {

    let chart = useRef(null)
    let [chartEl, setChartEl] = useState(chart)



    useEffect(() => {
        if (resize) {
            chartEl.resize()
        }
        if (!chartEl.current) {
            chartEl.setOption(option)
        }
        else {
            // console.log(resizeChart)
            setChartEl(echarts.init(chart.current))
        }
    }, [option, chartEl, resize])

    return (
        <div className="chart" ref={chart}></div>
    )
}

How to fix the setoptions doesn't exist on type MutableRefObject. What I'm trying to do is to display the line chart canvas. but there's a error which is setoptions doesn't exist on type mutablerefobject also the Property 'resize' does not exist on type 'MutableRefObject

question from:https://stackoverflow.com/questions/65934253/how-to-fix-the-setoption-does-not-exist-on-type-mutablerefobject-in-react

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...