🐈

Reactでオブジェクト指向やってみる #状態管理ライブラリ一切不要

に公開
4

Discussion

llc_starhacksllc_starhacks

お持ち帰り用Code:

/**
 * @ref: https://zenn.dev/llc_starhacks/articles/929e58b503d6ce
 */
class ChatRoom extends Room {...}
chatRoom.messages.create({ title, body, from: User, to: User });
chatRoom.messages[n].update({ title, body });

class PrivateChatRoom extends ChatRoom {...}
privateChatRoom.messages[n].update({ title, body });

const data = await room.fetch();
privateChatRoom.delete();

const [name, setName] = useState('ハリー・ポッターと秘密の部屋');
const room = new Room({ name, setName });
room.name // stated variable
room.setName('アズカバンの部屋');
Hidden comment