最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

next.js - Can't modify storage LiveObject while using liveblocks - Stack Overflow

matteradmin7PV0评论

I am trying to implement a storage LiveObject, when I try to modify it using set method, inside useMutation hook, it gives error "TypeError: thisCentralCard.set is not a function" :

Below is the useMutation hook I tried implementing, which is similar to the example shown in liveblocks storage tutorial.

const updateCentralCard = useMutation(({ storage }, newCard: Card) => {
    const thisCentralCard = storage.get("centralCard") as LiveObject<{color: string, value: string}>;
    console.log(thisCentralCard)
    
    thisCentralCard.set("color", newCard.color);
    thisCentralCard.set("value", newCard.value);
  }, []);
Post a comment

comment list (0)

  1. No comments so far