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

usePerformanceObserver #32

Open
ezekielchentnik opened this issue Oct 26, 2018 · 0 comments
Open

usePerformanceObserver #32

ezekielchentnik opened this issue Oct 26, 2018 · 0 comments

Comments

@ezekielchentnik
Copy link

ezekielchentnik commented Oct 26, 2018

performance-observer

example api:

function Logger() {
  const [entries] = usePerformanceObserver({
    entryTypes: ["measure"]
  });

  return (
    <table>
      <thead>
        <tr>
          <th>Name</th>
          <th>Entry Type</th>
          <th>Start Time</th>
          <th>Duration</th>
        </tr>
      </thead>
      <tbody>
        {entries.map(entry => (
          <tr key={entry.name}>
            <td>{entry.name}</td>
            <td>{entry.entryType}</td>
            <td>{entry.startTime}</td>
            <td>{entry.duration}</td>
          </tr>
        ))}
      </tbody>
    </table>
  );
}
function ThingToMeasure() {
  const [performance] = useGlobal(["performance"]); // pass window.performance through context

  function measureClick(evt) {
    performance.measure("button clicked");
  }

  return <button onClick={measureClick}>Measure</button>;
}


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

1 participant