Sha256: 49e7d05f013f3c024d774eea97d82211ca494cdb307d47b46a307f437a197b14

Contents?: true

Size: 1.2 KB

Versions: 1

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-ddd92820.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

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-16.1.0 entry_types/scrolled/package/frontend/PhonePlatformContext-10a1d600.js