/-----------------"Это store"--------------------------/
import { runInAction, makeAutoObservable } from "mobx";
import { getComics } from "../Api/comics/comics";
import { IComics } from "../types/comics";
class ComicsStore {
comicsList: IComics[] = [];
constructor() {
makeAutoObservable(this);
}
setComicsList = () => {
runInAction(async () => {
try {
const {data} = await getComics();
this.comicsList = data.results
} catch (error) {
console.log(error);
}
})
}
};
export default new ComicsStore;
/----------------------Это Контент------------------------------/
import {observer} from 'mobx-react-lite';
import comicsStore from '../../store/comicsStore';
import react, {useEffect} from 'react'
const Comics:React.FC = () => {
const {comicsList, setComicsList} = comicsStore;
useEffect(() => {
setComicsList();
},[])
return (
{comicsList.map(({id, images, title}) => (
{images}
{title}
))}
)
}
export default observer(Comics);
/-------------------Это ошибка------------------------/
derivation.ts:144 [MobX] Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: ComicsStore@1.comicsList