Skip to content

React callback guidance #211

@FTWinston

Description

@FTWinston

Hi, I noticed that the documentation on how to use client-side callbacks with react is "TODO".

I wanted an immutable version of my state on the client, so that it worked nicely with react props. I've got a reasonably complicated state tree, and ran into a few issues keeping track of listeners at different levels of my state tree.

Having given up on managing listeners myself, I made the following hook. This uses callbacks to provide react with immutable snapshots of mutable room states:
https://gist.github.com/FTWinston/61cefee837d50a492858fd3857396f37

Is this anything like what you might have planned for the react documentation? It's working for changes to arrays inside objects inside a map, though I haven't tested it extensively.

Would you be interested in a PR that links to this gist? That might be useful to share, until proper documentation is available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions