Sha256: fa183c527bcde91888a925583e99e66e9127672f8587c54a854cf577a229d938

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

import { browser } from 'pageflow/frontend';
import React, { createContext, useContext, useState, useEffect } from 'react';
import { _ as _slicedToArray } from './i18n-71c39823.js';

var BrowserFeaturesAvailableContext = createContext(); // Browser feature detection is not available during server side
// rendering. To prevent mismatches during hydration, we keep features
// disabled in the initial render. Since hydration only starts after
// feature detection has finished, we can immediately re-render once
// the provider has mounted.

function BrowserFeaturesProvider(_ref) {
  var children = _ref.children;

  var _useState = useState(false),
      _useState2 = _slicedToArray(_useState, 2),
      isAvailable = _useState2[0],
      setIsAvailable = _useState2[1];

  useEffect(function () {
    return setIsAvailable(true);
  }, []);
  return /*#__PURE__*/React.createElement(BrowserFeaturesAvailableContext.Provider, {
    value: isAvailable
  }, children);
}
function useBrowserFeature(name) {
  return useContext(BrowserFeaturesAvailableContext) && browser.has(name);
}

var PhonePlatformContext = React.createContext(false);

export { BrowserFeaturesProvider as B, PhonePlatformContext as P, useBrowserFeature as u };

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pageflow-17.0.4 entry_types/scrolled/package/frontend/PhonePlatformContext-b28d991a.js
pageflow-17.0.3 entry_types/scrolled/package/frontend/PhonePlatformContext-b28d991a.js
pageflow-17.0.2 entry_types/scrolled/package/frontend/PhonePlatformContext-b28d991a.js
pageflow-17.0.1 entry_types/scrolled/package/frontend/PhonePlatformContext-b28d991a.js
pageflow-17.0.0 entry_types/scrolled/package/frontend/PhonePlatformContext-b28d991a.js
pageflow-16.2.0 entry_types/scrolled/package/frontend/PhonePlatformContext-b28d991a.js