JSFiddle - React, Tailwind, and code Playground

by Esteban Herrera

JavaScript

async componentDidMount() {
  this.db = await this.createDatabase();


  const sub = 
    this.db.messages.find().sort({id: 1}).$.subscribe(messages => {
    if (!messages)
      return;
    toast('Reloading messages');
    this.setState({messages: messages});
  });
  this.subs.push(sub);
}