8000 [Bug] Lifecycle callback did not trigger in react-vchart · Issue #3792 · VisActor/VChart · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Bug] Lifecycle callback did not trigger in react-vchart #3792
Closed
@xiaoluoHe

Description

@xiaoluoHe

Version

latest

Link to Minimal Reproduction

none

Steps to Reproduce

如图,仅打印了 onReady

Image

本地启动简单 demo,也是一样:

Image

const getData = () =>
  ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'].map(time => ({
    time,
    value: Math.random() * 40
  }));

const root = document.getElementById(CONTAINER_ID);
const { VChart, BarChart, Bar } = ReactVChart;
const { useState, useRef, useEffect } = React;

const Card = () => {
  const [data, setData] = useState(getData());
  const chartRef = useRef(null);
  useEffect(() => {
    window['vchart'] = chartRef;
  }, []);

  const handleSwitchData = () => {
    setData(getData());
  };

  const handleBarClick = params => {
    console.log(params);
  };

  return (
    <div>
      <BarChart ref={chartRef} data={[{ id: 'id0', values: data }]}
        onReady={() => console.log('onReady')}
        onInitialized={() => console.log('onInitialized')}
        onRendered={() => console.log('onRendered')}
        onLayoutEnd={() => console.log('onLayoutEnd')}
        onRenderFinished={() => console.log('onRenderFinished')}
      >
        <Bar
          xField="time"
          yField="value"
          bar={{
            state: {
              hover: {
                fill: 'black'
              }
            }
          }}
          onClick={handleBarClick}
        />
      </BarChart>
      <button
        style={{ position: 'absolute', top: 0, left: '50%', transform: 'translate(-50%, 0)' }}
        onClick={handleSwitchData}
      >
        Switch Data
      </button>
    </div>
  );
};

ReactDom.createRoot(root).render(<Card />);

// release react instance, do not copy
window.customRelease = () => {
  ReactDom.unmountComponentAtNode(root);
};

Current Behavior

只触发了 onReady

Expected Behavior

其他相应钩子正常触发

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0