This package has been deprecated

Author message:

this package has been deprecated

prelaks

0.0.1 • Public • Published

Prelaks

Prelaks is the Preact version of Relaks. It works the same way as the React version. The only difference is that renderAsync() receives three additional parameters: props, state, and context.

Example

import { h } from 'preact';
import { AsyncComponent } from 'prelaks';

class StoryView extends AsyncComponent {

    renderAsync(meanwhile, props) {
        let db = props.database;
        let query = {
            table: 'story',
            criteria: {
                id: props.storyID
            }
        };
        meanwhile.show(<div>Loading</div>);        
        return db.findOne(query).then((story) => {
            return (
                <div>
                    <h1>{story.title}</h1>
                    <p>{story.text}</p>
                </div>
            );
        });
    }
}

Example using async/await

import { h } from 'preact';
import { AsyncComponent } from 'prelaks';

class StoryView extends AsyncComponent {

    async renderAsync(meanwhile, props) {
        let db = props.database;
        let query = {
            table: 'story',
            criteria: {
                id: props.storyID
            }
        };
        meanwhile.show(<div>Loading</div>);        
        let story = await db.findOne(query);
        return (
            <div>
                <h1>{story.title}</h1>
                <p>{story.text}</p>
            </div>
        );
    }
}

Readme

Keywords

Package Sidebar

Install

npm i prelaks

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

23.8 kB

Total Files

10

Last publish

Collaborators

  • cleong