mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
26 lines
706 B
JavaScript
26 lines
706 B
JavaScript
// @flow
|
|
|
|
import React, { useCallback, useContext } from 'react';
|
|
import { ProfilerContext } from './ProfilerContext';
|
|
import Button from '../Button';
|
|
import ButtonIcon from '../ButtonIcon';
|
|
import { StoreContext } from '../context';
|
|
|
|
export default function ClearProfilingDataButton() {
|
|
const store = useContext(StoreContext);
|
|
const { didRecordCommits, isProfiling } = useContext(ProfilerContext);
|
|
const { profilerStore } = store;
|
|
|
|
const clear = useCallback(() => profilerStore.clear(), [profilerStore]);
|
|
|
|
return (
|
|
<Button
|
|
disabled={isProfiling || !didRecordCommits}
|
|
onClick={clear}
|
|
title="Clear profiling data"
|
|
>
|
|
<ButtonIcon type="clear" />
|
|
</Button>
|
|
);
|
|
}
|