Commit e1290d8e authored by Shuai Chen's avatar Shuai Chen

perf: use requestAnimationFrame

parent 9da468f4
...@@ -33,7 +33,6 @@ export default class ActiveChart extends Component { ...@@ -33,7 +33,6 @@ export default class ActiveChart extends Component {
} }
loopData = () => { loopData = () => {
this.requestRef = requestAnimationFrame(() => {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.setState( this.setState(
{ {
...@@ -43,8 +42,7 @@ export default class ActiveChart extends Component { ...@@ -43,8 +42,7 @@ export default class ActiveChart extends Component {
this.loopData(); this.loopData();
} }
); );
}, 1000); }, 500);
});
}; };
render() { render() {
......
...@@ -24,9 +24,11 @@ class AsyncLoadBizCharts extends React.Component { ...@@ -24,9 +24,11 @@ class AsyncLoadBizCharts extends React.Component {
async componentDidMount() { async componentDidMount() {
await loadBizCharts(); await loadBizCharts();
requestAnimationFrame(() => {
this.setState({ this.setState({
loading: false, loading: false,
}); });
});
} }
render() { render() {
......
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import numeral from 'numeral'; import numeral from 'numeral';
import ChartCard from './ChartCard'; import ChartCard from './ChartCard';
import Field from './Field';
const getComponent = Component => { const getComponent = Component => {
return props => { return props => {
return ( return (
<Suspense fallback={null}> <Suspense fallback="...">
<Component {...props} /> <Component {...props} />
</Suspense> </Suspense>
); );
...@@ -19,7 +20,6 @@ const Gauge = getComponent(React.lazy(() => import('./Gauge'))); ...@@ -19,7 +20,6 @@ const Gauge = getComponent(React.lazy(() => import('./Gauge')));
const MiniArea = getComponent(React.lazy(() => import('./MiniArea'))); const MiniArea = getComponent(React.lazy(() => import('./MiniArea')));
const MiniBar = getComponent(React.lazy(() => import('./MiniBar'))); const MiniBar = getComponent(React.lazy(() => import('./MiniBar')));
const MiniProgress = getComponent(React.lazy(() => import('./MiniProgress'))); const MiniProgress = getComponent(React.lazy(() => import('./MiniProgress')));
const Field = getComponent(React.lazy(() => import('./Field')));
const WaterWave = getComponent(React.lazy(() => import('./WaterWave'))); const WaterWave = getComponent(React.lazy(() => import('./WaterWave')));
const TagCloud = getComponent(React.lazy(() => import('./TagCloud'))); const TagCloud = getComponent(React.lazy(() => import('./TagCloud')));
const TimelineChart = getComponent(React.lazy(() => import('./TimelineChart'))); const TimelineChart = getComponent(React.lazy(() => import('./TimelineChart')));
......
...@@ -25,7 +25,6 @@ class Analysis extends Component { ...@@ -25,7 +25,6 @@ class Analysis extends Component {
}; };
componentDidMount() { componentDidMount() {
console.log('run');
const { dispatch } = this.props; const { dispatch } = this.props;
this.reqRef = requestAnimationFrame(() => { this.reqRef = requestAnimationFrame(() => {
dispatch({ dispatch({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment