How to use the mobx-react-lite.observer function in mobx-react-lite

To help you get started, we’ve selected a few mobx-react-lite 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 wexond / desktop / src / renderer / views / newtab / components / NewsItem / index.tsx View on Github external
import * as React from 'react';
import { observer } from 'mobx-react-lite';

import {
  StyledNewsItem,
  Img,
  Info,
  Title,
  Footer,
  Source,
  Fill,
  Description,
} from './style';
import { INewsItem } from '~/interfaces/news-item';

export const NewsItem = observer(
  ({
    item,
    column,
    row,
    width,
    height,
  }: {
    item: INewsItem;
    column: number;
    row: number;
    width: number;
    height: number;
  }) => {
    // eslint-disable-next-line prefer-const
    let [img, setImg] = React.useState('');
github choerodon / devops-service / react / components / tree-view / index.js View on Github external
const children = record.children;

    if (children && children.length) {
      const key = record.get('key');
      expendedKeys.push(key);
      record.isExpanded = true;
    }

    const parent = record.parent;
    if (parent && !parent.isExpanded) {
      expandParents(parent, expendedKeys);
    }
  }
}

const TreeView = observer(({ ds, store, nodesRender, searchAble }) => {
  const treeClass = useMemo(() => classnames({
    'c7ncd-menu-wrap': true,
    'c7ncd-menu-scroll': searchAble,
  }), [searchAble]);

  const nodeRenderer = useCallback(({ record }) => nodesRender(record, store.getSearchValue),
    [store.getSearchValue]);

  function handleSearch(value) {
    const realValue = value || '';
    const expandedKeys = [];

    // NOTE: 让多个 action 只执行一次
    runInAction(() => {
      /**
       *
github choerodon / test-manager-service / react / routes / TestPlan / components / UpdateRemindModalChildren / UpdateRemindModalChildren.js View on Github external
<div>
        <span>变更内容</span>
        <div>
          
          <div>
            
          </div>
          
        </div>
      </div>
    
  );
}; 

export default observer(UpdateRemindModalChildren);
github choerodon / devops-service / react / routes / resource / main-view / contents / application / modals / network2 / network-form / index.js View on Github external
}
          <button color="primary">
            {formatMessage({ id: 'network.config.addport' })}
          </button>
        
      
    
  );
}

export default observer(FormContent);
github fpw / SoCDP8 / src / client / src / components / peripherals / ASR33.tsx View on Github external
*   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see .
 */

import * as React from "react";
import { observer } from 'mobx-react-lite';

export interface ASR33Props {
    punchData: string;
    onReaderKey(chr: number): void;
    onReaderClear(): void;
    onTapeLoad(tape: File): void;
    onReaderActivationChange(state: boolean): void;
}

export const ASR33: React.FunctionComponent = observer((props) =&gt; {
    const textRef = React.useRef(null);

    scrollToBottomOnChange(textRef);

    return (
        <section>
            <div>
                <h2>Output</h2>
                <div>
                    <textarea value="{props.punchData}" style="{{fontFamily:" cols="{80}" rows="{8}" readonly="">                &lt;/div&gt;

                &lt;div className='control'&gt;
                    &lt;button className='button' onClick={props.onReaderClear}&gt;Clear Output&lt;/button&gt;</textarea></div></div></section>
github wexond / desktop / src / renderer / views / bookmarks / components / Bookmark / index.tsx View on Github external
win.focus();
  }
};

const onMoreClick = (data: IBookmark) => (e: any) => {
  e.stopPropagation();

  const { left, top } = e.currentTarget.getBoundingClientRect();

  store.menuVisible = true;
  store.menuLeft = left;
  store.menuTop = top;
  store.currentBookmark = data;
};

export const Bookmark = observer(({ data }: { data: IBookmark }) => {
  const selected = store.selectedItems.includes(data._id);

  let favicon = data.favicon;
  let customFavicon = false;

  if (data.isFolder) {
    favicon = icons.folder;
    customFavicon = true;
  } else {
    if (favicon) {
      if (favicon.startsWith('data:image')) {
        favicon = data.favicon;
      } else {
        favicon = store.favicons.get(data.favicon);
      }
    } else {
github qusly / qusly / src / renderer / app / components / PathView / index.tsx View on Github external
page.path.push(input.value.trim());
    store.pathView.inputVisible = false;
  } else if (e.key === 'Escape') {
    store.pathView.inputVisible = false;
  }
};

const onBlur = () =&gt; {
  store.pathView.inputVisible = false;
}

const onContextMenu = () =&gt; {
  store.contextMenu.show('path');
}

export const PathView = observer(() =&gt; {
  const page = store.pages.current;
  if (!page) return null;

  return (
    
      
        {page.path.items.map((label, index) =&gt; (
          {label}
        ))}
github wexond / desktop / src / renderer / views / app / components / Overlay / views / default / TabGroup / index.tsx View on Github external
const onInput = (item: ITabGroup) =&gt; (e: any) =&gt; {
  item.name = e.currentTarget.value;
};

const onBlur = (item: ITabGroup) =&gt; () =&gt; {
  item.editMode = false;
};

const onKeyPress = (item: ITabGroup) =&gt; (e: any) =&gt; {
  if (e.key === 'Enter') {
    item.editMode = false;
  }
};

export const TabGroup = observer(({ data }: { data: ITabGroup }) =&gt; {
  const { name, color, id, editMode } = data;

  return (
    
      {editMode &amp;&amp; (

mobx-react-lite

Lightweight React bindings for MobX based on React 16.8+ and Hooks

MIT
Latest version published 7 months ago

Package Health Score

96 / 100
Full package analysis