Questions tagged [MobX] (1)

1
answer

How to write asynchronous jest a test for action // mobx?

Himself action addItem = text => { axios.post("/task", { headers: { "Content-Type": "application/json" }, text: text }) .then(res => { this.arr.push(res.data.task); }) .catch(e => console.log(e)); }; I tried something like this, did not work, I get this error TypeError: Cannot read property 'then' of undefine...
justine asked April 9th 20 at 10:50
0
answer

Why not rerender component when you update the Stora?

I'm trying to make a jet counter, as an example of a simple component in conjunction react+mobx+mobx-react+next. When you click on the button in the developer console mobx appears that the action is triggered, but the page data is not updated. In this case, if the output is not tick, and the ticks getter, shows in General N...
nya_Crooks30 asked April 9th 20 at 09:35
2
answers

What to use React Mobx or Redux?

What is more convenient(easier to understand)? What use are you?
June2 asked April 8th 20 at 18:01
1
answer

Enzyme tests(snapshot) do not work if the tested component has the annotation @observer(mobx), how to fix?

Hello, everyone! I have a problem with writing tests for a project. The project has mobx store. Enzyme tests(snapshot) do not work if the tested component has the annotation @observer (mobx). Get the error message: Test suite failed to run TypeError: Cannot read property 'componentWillReact' of undefined Test: const prop...
destiny asked April 8th 20 at 02:22
0
answer

How correctly to transfer a method from Stora in formik to handle server-side errors?

Hello! I have a post method in the store signUpUser.import { configure observable, action, runInAction, } from 'mobx'; import from axios 'axios'; import get from 'lodash/get'; configure({ enforceActions: 'observed' }); type codeType = number | null; export class UserStore { @observable status: string = 'pending'; @obs...
nikolas.Farrell asked April 4th 20 at 01:01
2
answers

How to test a component with the local stor MobX?

There is a component class in its constructor initializes a local store MobX like this:constructor(props) { super(props); this.store = new SubscribeStore({ userId: this.props.userId type: this.props.isFollowers ? 'followers' : 'subscriptions' }); } In the end, the stor lies in this writing test can't find a way to contr...
Henderson_Reichel asked April 3rd 20 at 18:39
2
answers

Mobx: how rerendering container, transmitting child component observable from the Stora?

Mobx rerendered observer component only when this component refers to the observable structure. I. e. if to divide the component into the container and the Presentation component, the Container will not rerendered, respectively, the Presentation component receives the updated data.import React { Component } from 'react'; im...
Sister_Waelchi45 asked April 1st 20 at 17:23
0
answer

Is it possible to directly change the state Mobx?

Is it possible to directly change the state Mobx or you want to create action?
Alberta2 asked April 1st 20 at 16:42
1
answer

How to use decorators in reactjs mobx?

Decided to use mobx instead of redux, swears on @observer:Support for the experimental syntax 'decorators-legacy' isn't currently enabled Yesterday I spent 6 hours, used a different bunch of libraries and tutorials. To work without decorators in mobx not very convenient, and manuals are all decorators. How to fix this erro...
Taryn_Rath asked April 1st 20 at 16:07
0
answer

What structure store better to do for such a react component?

There is a component of the news, he may have several groups, each group can have multiple subgroups. Field set for sub-groups is always the same. Subgroups are always added to the end of the group, and to remove a subgroup from anywhere. Schematically it looks like this - Maybe there are some best practices with something...
jerald_Streich34 asked March 31st 20 at 21:57