How to use the mobx-react.useObserver function in mobx-react

To help you get started, we’ve selected a few mobx-react 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 orbitdb / orbit-web / src / containers / ControlPanel.js View on Github external
className="icon flaticon-sharing7"
          // onClick={onOpenSwarmView}
          style={{ ...uiStore.theme }}
          key="swarmIcon"
        /> */}
        <div> sessionStore.logout()}
          style={{ ...uiStore.theme }}
          key='disconnectIcon'
        /&gt;
      </div>
    )
  }

  return useObserver(() =&gt;
    uiStore.isControlPanelOpen &amp;&amp; sessionStore.isAuthenticated ? (
      &lt;&gt;
        <div>
          <div style="{{">
            
          </div>
</div>
github PacktPublishing / Learn-React-Hooks / Chapter13 / chapter13_3 / src / AddTodo.js View on Github external
this.value = val
    }
  }))

  function handleInput (e) {
    inputStore.updateFromInput(e)
  }

  function handleAdd () {
    if (inputStore.value) {
      todoStore.addTodo(inputStore.value)
      inputStore.update('')
    }
  }

  return useObserver(() =&gt; (
    <form> { e.preventDefault(); handleAdd() }}&gt;
      <input value="{inputStore.value}" style="{{" placeholder="enter new task..." type="text">
      <input value="add" disabled="{inputStore.disabled}" style="{{" type="submit">
    </form>
  ))
github webclipper / web-clipper / src / pages / preference / base.tsx View on Github external
id="preference.basic.liveRendering.title"
          defaultMessage="LiveRendering"
        /&gt;
      ),
      description: (
        
      ),
    },
  ];

  const configService = Container.get(IConfigService);

  const configs = useObserver(() =&gt; {
    if (configService.isLatestVersion) {
      return originConfigs;
    }
    return originConfigs.concat({
      key: 'update',
      action: (
        <a href="https://github.com/webclipper/web-clipper/releases">
          
        </a>
      ),
      title: ,
      description: (
github webclipper / web-clipper / src / pages / preference / changelog / index.tsx View on Github external
const Changelog: React.FC = () =&gt; {
  const { locale } = useSelector(({ userPreference: { locale } }: GlobalStore) =&gt; {
    return {
      locale,
    };
  });
  const configService = Container.get(IConfigService);
  const workLocale = useObserver(() =&gt; {
    let workLocale = 'en-US';
    if (configService.config?.changelogLocale.some(o =&gt; o !== locale)) {
      workLocale = locale;
    }
    return workLocale;
  });

  const { loading, result: changelog } = useAsync(
    () =&gt; request.get(`${config.resourceHost}/changelog/CHANGELOG.${workLocale}.md`),
    []
  );

  if (loading || !changelog) {
    return ;
  }
  return ;
github AugurProject / augur / packages / orbit-web / src / containers / ChannelHeader.js View on Github external
function ChannelHeader () {
  const location = useLocation()
  const { channel } = useParams()
  const { networkStore, uiStore } = useContext(RootContext)
  const [t] = useTranslation()

  function handleMenuButtonClick (e) {
    e.stopPropagation()
    uiStore.openControlPanel()
  }

  const overrideName = t(`viewNames.${location.pathname.slice(1)}`)

  return useObserver(() =&gt; (
    <div>
      <div>
        {networkStore.unreadEntriesCount &gt; 0 ? (
          <span>{networkStore.unreadEntriesCount}</span>
        ) : null}
      </div>
      {/*<div>{channel ? `#${channel}` : overrideName}</div>*/}
    </div>
  ))
}
github orbitdb / orbit-web / src / containers / ChannelHeader.js View on Github external
function ChannelHeader () {
  const location = useLocation()
  const { channel } = useParams()
  const { networkStore, uiStore } = useContext(RootContext)
  const [t] = useTranslation()

  function handleMenuButtonClick (e) {
    e.stopPropagation()
    uiStore.openControlPanel()
  }

  const overrideName = t(`viewNames.${location.pathname.slice(1)}`)

  return useObserver(() =&gt; (
    <div>
      <div style="{{">
        {networkStore.unreadEntriesCount &gt; 0 ? (
          <span>{networkStore.unreadEntriesCount}</span>
        ) : null}
      </div>
      <div>{channel ? `#${channel}` : overrideName}</div>
    </div>
  ))
}
github PacktPublishing / Learn-React-Hooks / Chapter13 / chapter13_3 / src / TodoItem.js View on Github external
export default function TodoItem ({ item }) {
  const todoStore = useTodoStore()
  
  function handleToggle () {
    todoStore.toggleTodo(item.id)
  }

  function handleRemove () {
    todoStore.removeTodo(item.id)
  }

  return useObserver(() =&gt; {
    const { title, completed } = item
    return (
      <div style="{{">
        <input checked="{completed}" type="checkbox">
        {title}
        <button style="{{">x</button>
      </div>
    )
  })
}
github orbitdb / orbit-web / src / containers / ChannelStatus.js View on Github external
function ChannelStatus ({ channel, theme }) {
  const [t] = useTranslation()
  return useObserver(() =&gt; {
    const userCount = channel ? channel.userCount : 0
    return (
      <div style="{{">
        {userCount} {t('channel.status.users', { count: userCount })}
      </div>
    )
  })
}
github AugurProject / augur / packages / orbit-web / src / views / App.js View on Github external
function App () {
  return (
    
      
        {useObserver(() =&gt; (
          
        ))}
      
    
  )
}
github orbitdb / orbit-web / src / containers / ChannelControls.js View on Github external
} catch (err) {
      logger.error(err)
      throw err
    }
  }

  async function sendFiles (files) {
    try {
      await channel.sendFiles(files)
    } catch (err) {
      logger.error(err)
      throw err
    }
  }

  return useObserver(() =&gt; (
    <div>
      
      
      
    </div>
  ))
}