DEV Community

Discussion on: Preact Composition API

Collapse
 
mindplay profile image
Rasmus Schultz

Using named exports alow for better tree-shaking and better minification, making all composition functions optional.

True.

But it doesn't have to be OOP - that was just an example.

We can do the same thing with functions:

const Comp = createComponent(component => {
    const filterRef = ref(component, 'ALL');
    const filteredItems = watch(
        component,
        [props => props.items, filterRef],
        ([items, filter]) => filterItems(items, filter)
    );
    return () => <ItemList items={filteredItems.value} />;
});

My only point is don't hide your dependencies in global state.

Thread Thread
 
porfirioribeiro profile image
Porfirio

I see your ideas.
Would be nice to discuss this better. Could you post your concern on the PR github.com/preactjs/preact/pull/1923
or on Preact Slack
preact.slack.com/

Thread Thread
 
mindplay profile image
Rasmus Schultz

Done 🙂