mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
a9b3ca7fa7
Summary: I'm changing all callsites to use either global or scoped perf logger explicitly in one diff. `GlobalPerformanceLogger` is basically a singleton `scopedPerformanceLogger` is scoped to the React tree by using a React Context Reviewed By: sahrens Differential Revision: D14186694 fbshipit-source-id: 062c76eea8fce9d9b531f0eddf153bb79d52f68d
28 lines
854 B
JavaScript
28 lines
854 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import * as React from 'react';
|
|
import GlobalPerformanceLogger from 'GlobalPerformanceLogger';
|
|
import type {IPerformanceLogger} from 'createPerformanceLogger';
|
|
|
|
/**
|
|
* This is a React Context that provides a scoped instance of IPerformanceLogger.
|
|
* We wrap every <AppContainer /> with a Provider for this context so the logger
|
|
* should be available everywhere in your components.
|
|
* See React docs about using Context: https://reactjs.org/docs/context.html
|
|
*/
|
|
const PerformanceLoggerContext: React.Context<
|
|
IPerformanceLogger,
|
|
> = React.createContext(GlobalPerformanceLogger);
|
|
|
|
module.exports = PerformanceLoggerContext;
|