Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting 3 console.logs #1

Open
iqbal125 opened this issue Jul 24, 2019 · 3 comments
Open

getting 3 console.logs #1

iqbal125 opened this issue Jul 24, 2019 · 3 comments

Comments

@iqbal125
Copy link

iqbal125 commented Jul 24, 2019

I am getting 3 console logs I dont know why. I tried everything hooks/classes inside outside component and it doesnt work.

image

import React, { useEffect, Component } from 'react';
import ContextState from './context_state_config';
import history from './utils/history';
import ReactGA from 'react-ga';
import { observe } from 'react-performance-observer';

ReactGA.initialize('UA-144556525-1');

history.listen((location) => {
    ReactGA.pageview(location.pathname + location.search);
});

var observer = observe(measurements => {
  console.log(measurements);
});

class App extends Component {

  // var observer = new PerformanceObserver(list => {
  //     list.getEntries().forEach(entry => {
  //       // Display each reported measurement on console
  //       if (console) {
  //         console.log("Name: "       + entry.name      +
  //                     ", Type: "     + entry.entryType +
  //                     ", Start: "    + entry.startTime +
  //                     ", Duration: " + entry.duration  + "\n");
  //       }
  //     })
  //   });
  //   observer.observe({entryTypes: ['resource', 'mark', 'measure']});
  //   performance.mark('registered-observer');
  //
  //   function clicked(elem) {
  //     performance.measure('button clicked');
  //   }

  render() {
    return(
      <div>
        React
        <ContextState />
      </div>
    )
  }
}


export default App;

@jamiebuilds
Copy link
Owner

Are you sure your app isn't rendering 3 separate times?

@iqbal125
Copy link
Author

@jamiebuilds hey thanks for the quick response! you were right.

If you can help me understand one more thing. Im getting 2 different values when Im using the react-performance-observer and the regular performance observer. Can you help me understand why.

image

image

@jamiebuilds
Copy link
Owner

Hm, I'm not sure. Are those logging in the same run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants