How to use the react-use.useMedia function in react-use

To help you get started, we’ve selected a few react-use examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / gatsby-theme-antv / @antv / gatsby-theme-antv / site / components / PlayGround.tsx View on Github external
console.error(e); // eslint-disable-line no-console
          setError(e);
          return;
        }
        setError(null);
      }}
      editorDidMount={instance => {
        cmInstance.current = instance;
      }}
    />
  );

  const fileExtension =
    relativePath.split('.')[relativePath.split('.').length - 1] || 'js';

  const isWide = useMedia('(min-width: 767.99px)', true);

  return (
    <div>
      
        <div>
          {error ? (
            </div></div>
github antvis / gatsby-theme-antv / @antv / gatsby-theme-antv / site / components / Header.tsx View on Github external
}
  }, [path]);

  // 移动端下弹出菜单时,禁止页面滚动
  useEffect(() =&gt; {
    if (popupMenuVisible) {
      document.documentElement.style.overflow = 'hidden';
    } else {
      document.documentElement.style.overflow = '';
    }
    return () =&gt; {
      document.documentElement.style.overflow = '';
    };
  }, [popupMenuVisible]);

  const isWide = useMedia('(min-width: 767.99px)', true);
  const menuIcon = !isWide ? (
    
  ) : null;

  const productItemProps = isWide
    ? {
        onMouseEnter: onProductMouseEnter,
        onMouseLeave: onProductMouseLeave,
      }
    : {
        onClick: onToggleProductMenuVisible,
      };
github bunkerchat / bunker / src / features / room / Room.jsx View on Github external
const Room = ({ rooms, activeRoomId }) =&gt; {
	const isDesktop = useMedia("(min-width: 720px)");

	if (!activeRoomId) return null;

	return (
		
			
				

				{_.map(rooms, (room, roomId) =&gt; (
					
				))}
				
			
			{isDesktop &amp;&amp; }
		
	);
github antvis / gatsby-theme-antv / @antv / gatsby-theme-antv / site / templates / example.tsx View on Github external
<span>
                    {doc &amp;&amp; doc.title
                      ? capitalize(doc.title[i18n.language])
                      : menuItemLocaleKey}
                  </span>
                
              }
            &gt;
              {renderMenuItems(groupedEdges[slugString])}
            
          );
        })}
    
  );

  const isWide = useMedia('(min-width: 767.99px)', true);
  const [drawOpen, setDrawOpen] = useState(false);
  const menuSider = isWide ? (
    
      {menu}
    
  ) : (
    
      }
      wrapperClassName={styles.menuDrawer}
      onChange={open =&gt; setDrawOpen(!!open)}
      width={280}
github ChristopherBiscardi / christopherbiscardi.github.com / www / src / blog-post.js View on Github external
const WebMentions = props =&gt; {
  const layers = useLayers();
  const textColor = useTextColor();
  const isWide = useMedia("(min-width: 480px)");
  return (
    <div>
      Web Mentions
      {props.mentions.edges.map(({ node }) =&gt; {
        const { content, author } = node;
        return (
          </div>
github antvis / gatsby-theme-antv / @antv / gatsby-theme-antv / site / templates / document.tsx View on Github external
const menu = (
    <menu style="{{" mode="inline"> setOpenKeys(currentOpenKeys)}
      inlineIndent={16}
      forceSubMenuRender
    &gt;
      {renderMenu(menuData)}
    </menu>
  );

  const isWide = useMedia('(min-width: 767.99px)', true);
  const [drawOpen, setDrawOpen] = useState(false);
  const menuSider = isWide ? (
    
      {menu}
    
  ) : (
    
      }
      wrapperClassName={styles.menuDrawer}
      onChange={open =&gt; setDrawOpen(!!open)}
      width={280}