Реакция: Не удается прочитать свойство 'readContext' из неопределенного

time.clock() имеет 13 десятичных знаков в Windows, но только два в Linux. time.time() имеет 17 десятичных знаков в Linux и 16 в Windows, но фактическая точность отличается.

Я не согласен с документацией, что time.clock() следует использовать для бенчмаркинга на Unix / Linux. Это не достаточно точно, поэтому используемый таймер зависит от операционной системы.

В Linux временное разрешение в time.time() велико:

>>> time.time(), time.time()
(1281384913.4374139, 1281384913.4374161)

В Windows, однако, функция времени, по-видимому, использует последний вызываемый номер:

>>> time.time()-int(time.time()), time.time()-int(time.time()), time.time()-time.time()
(0.9570000171661377, 0.9570000171661377, 0.0)

Даже если я пишу вызовы на разных строках в Windows, он все равно возвращает то же значение, поэтому реальная точность ниже.

Таким образом, при серьезных измерениях необходимо выполнить проверку платформы (import platform, platform.system()), чтобы определить, следует ли использовать time.clock() или time.time().

(Протестировано в Windows 7 и Ubuntu 9.10 с помощью python 2.6 и 3.1)

0
задан Hemadri Dasari 18 January 2019 в 13:27
поделиться

3 ответа

Измените/Замените код в СТАРОМ 'react-cache/cjs/react-cache.development.js''

-:

var currentOwner = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;

function readContext(Context, observedBits) {
  var dispatcher = currentOwner.currentDispatcher;
  if (dispatcher === null) {
    throw new Error('react-cache: read and preload may only be called from within a ' + "component's render. They are not supported in event handlers or " + 'lifecycle methods.');
  }
  return dispatcher.readContext(Context, observedBits);
}

НОВЫЙ-:

const ReactCurrentDispatcher =
  React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
    .ReactCurrentDispatcher;

function readContext(Context, observedBits) {
  const dispatcher = ReactCurrentDispatcher.current;
  if (dispatcher === null) {
    throw new Error(
      'react-cache: read and preload may only be called from within a ' +
        "component's render. They are not supported in event handlers or " +
        'lifecycle methods.',
    );
  }
  return dispatcher.readContext(Context, observedBits);
}
0
ответ дан Genius Coders 18 January 2019 в 13:27
поделиться

Обходной путь для этой проблемы, которую я нашел из Интернета, - это ...

Если вы просто хотите запустить программу в среде разработки, вы можете самостоятельно изменить код в 'response-cache / cjs / Reaction-cache.development.js': old:

    var currentOwner = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;

    function readContext(Context, observedBits) {
        var dispatcher = currentOwner.currentDispatcher;
        if (dispatcher === null) {
        throw new Error('react-cache: read and preload may only be called from within a ' + "component's render. They are not supported in event handlers or " + 'lifecycle methods.');
       }
       return dispatcher.readContext(Context, observedBits);
     }
[114 ] 'currentOwner' не используется, кроме как в функции readContext. Итак, вот новое:

      var currentDispatcher =      React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;

     function readContext(Context, observedBits) {
          var dispatcher = currentDispatcher.current;
          if (dispatcher === null) {
               throw new Error('react-cache: read and preload may only be called from within a ' + "component's render. They are not supported in event handlers or " + 'lifecycle methods.');
           }
          return dispatcher.readContext(Context, observedBits);
         }

И это работает в моем коде.

0
ответ дан Hemadri Dasari 18 January 2019 в 13:27
поделиться

Текущая альфа из react-cache@2.0.0-alpha.1 не совместима с недавно опубликованными react@16.8.0-alpha.0 и react-dom@16.8.0-alpha.0.

Понижение до react@16.7.0-alpha.1 и react-dom@16.7.0-alpha.1 до выпуска новой совместимой альфа-версии react-cache.

0
ответ дан Ganapati V S 18 January 2019 в 13:27
поделиться
Другие вопросы по тегам:

Похожие вопросы: