Skip to content
This repository was archived by the owner on Dec 31, 2020. It is now read-only.
This repository was archived by the owner on Dec 31, 2020. It is now read-only.

Component not updated #75

@dacz

Description

@dacz

Having component

const Name = observer(( { authorItem, ...other } ) => {
  // const author = toJS(authorItem).data;
  const author = authorItem.data;
  if (!author || !author.slug || !author.displayName) {
    return (<div>loading</div>);
  }

  return (
    <div className={ styles.name } { ...other }>
      <AuthorLink slug={ authorItem.data.slug }>
        { authorItem.data.displayName }
      </AuthorLink>
    </div>
  );
});

authorItem is observable class instance, that is updated asynchronously by different part of the app. First run displays "loading" (correct, no data still available). Then the item is updated, but the components is not (still shows "loading").

When I uncomment the line const author = toJS(authorItem).data;, the components starts updating correctly and correct data are displayed.

Am I doing something fundamentally wrong with mobx, here?

Thanks.

PS: I tried even to rewrite AuthorLink (observer) to accept authorItem (observable) and make dereferencing there… no change, still not updating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions