React 源代码:“真正的内部依赖”是什么意思

Sch*_*eme 15 reactjs

我正在浏览 React 源代码并注意到 ReactDOMFiberFBEntry.js ( https://github.com/facebook/react/blob/master/src/fb/ReactDOMFiberFBEntry.js )。

该文件有以下注释:

 // These are real internal dependencies that are trickier to remove:
Run Code Online (Sandbox Code Playgroud)

“真正的内部依赖”是什么意思内部反应自己,React Dom?我确定这是非常明显的,但我不太确定。在这种情况下,“真实”这个词还有多大意义?

来源:

/**
 * Copyright 2013-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

'use strict';

var ReactDOMFiber = require('ReactDOMFiberEntry');

Object.assign(
  ReactDOMFiber.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
  {
    // These are real internal dependencies that are trickier to remove:
    ReactBrowserEventEmitter: require('ReactBrowserEventEmitter'),
    ReactErrorUtils: require('ReactErrorUtils'),
    ReactFiberErrorLogger: require('ReactFiberErrorLogger'),
    ReactFiberTreeReflection: require('ReactFiberTreeReflection'),
    ReactDOMComponentTree: require('ReactDOMComponentTree'),
    ReactInstanceMap: require('ReactInstanceMap'),
    // This is used for ajaxify on www:
    DOMProperty: require('DOMProperty'),
    // These are dependencies of TapEventPlugin:
    EventPluginUtils: require('EventPluginUtils'),
    EventPropagators: require('EventPropagators'),
    SyntheticUIEvent: require('SyntheticUIEvent'),
  },
);

module.exports = ReactDOMFiber;
Run Code Online (Sandbox Code Playgroud)

lif*_*foo 13

正如Dan Abramov所指出的,该__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED对象包含 React 内部函数和状态。这些内部结构不适合从 React 公共 API 中使用。

\n

丹写道:

\n
\n

不,它\xe2\x80\x99s 使用起来不安全。这就是为什么它有一个可怕的名字的原因。我们不保证您访问那里的内容会发生什么。该行为可能会在任何版本上发生变化。如果您不希望该库稍后被破坏,我们强烈建议不要在您的库中触及它。

\n
\n