immerjs / immer

Create the next immutable state by mutating the current one

Home Page:https://immerjs.github.io/immer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Immer - Immer forbids circular references

NewvilleMedia opened this issue · comments

I am trying to query some post and I keep running into the same error: [Immer] Immer forbids circular references

import { DataStore } from '@aws-amplify/datastore';
import { Post } from '../../models'

export default function HomeScreen ({ navigation }) {
const [post, setPost] = useState([]);

const fetchPost = async () => {
const results = await DataStore.query(Post);
setPost(results);

};

useEffect(() => {
fetchPost();
}, []);

Correct, as documented Immer is designed for immutable trees. Something that has circular references is not a tree. If there are mutable objects in your tree that should be ignored, see the immerable symbol in the documentation on how to ignore those.