How to use the piral.useGlobalState function in piral

To help you get started, we’ve selected a few piral 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 smapiot / piral / src / samples / sample-piral / src / components / User.tsx View on Github external
export const User: React.FC = () => {
  const [open, setOpen] = React.useState(false);
  const currentUser = useGlobalState(m => m.user);
  const menuItems = useGlobalState(m => m.components.menuItems);
  const itemNames = Object.keys(menuItems).filter(m => menuItems[m].settings.type === 'user');
  const container = React.useRef(undefined);
  const image = currentUser ? require('../images/male.png') : require('../images/female.png');
  const items = itemNames.length > 0 && (
    <>
      <li>
      {itemNames.map(name =&gt; {
        const Component = menuItems[name].component;
        return ;
      })}
    
  );
  useOnClickOutside(container, () =&gt; setOpen(false));

  return (
    <div open=""></div></li>
github smapiot / piral / src / samples / sample-piral / src / components / User.tsx View on Github external
export const User: React.FC = () =&gt; {
  const [open, setOpen] = React.useState(false);
  const currentUser = useGlobalState(m =&gt; m.user);
  const menuItems = useGlobalState(m =&gt; m.components.menuItems);
  const itemNames = Object.keys(menuItems).filter(m =&gt; menuItems[m].settings.type === 'user');
  const container = React.useRef(undefined);
  const image = currentUser ? require('../images/male.png') : require('../images/female.png');
  const items = itemNames.length &gt; 0 &amp;&amp; (
    &lt;&gt;
      <li>
      {itemNames.map(name =&gt; {
        const Component = menuItems[name].component;
        return ;
      })}
    
  );
  useOnClickOutside(container, () =&gt; setOpen(false));

  return (</li>

piral

The all-in-one piral package.

MIT
Latest version published 6 days ago

Package Health Score

84 / 100
Full package analysis