Answer the question
In order to leave comments, you need to log in
Mobx: how to render container passing observable from store to child component?
Mobx only renders an observer component when an observable structure is accessed in that component. Those. if, split the component into a Container and a Presentation Component, the Container is not rendered, so the Presentation Component does not get updated data.
import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import TodoView from './Todo-view';
@inject('TasksModel')
@observer
class Todo extends Component {
render() {
const {
TasksModel: { tasks },
} = this.props;
return (
<TodoView tasks={tasks} />
);
}
}
export default Todo;
tasks.length;
, then it will consider that the observable is used, and the observer will re-render the container. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question