Skip to content

NMNMCC/Pureact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pureact

Component. State. Redefined.

import { component } from "..";

type Internals = {
    count: number;
};

const decrement = (data: Internals) => (): Internals => ({
    count: data.count - 1,
});
const increment = (data: Internals) => (): Internals => ({
    count: data.count + 1,
});

export const Counter = component<Internals>({ count: 0 }, ($, internals) => {
    return (
        <>
            <button onClick={$(decrement(internals))}>-1</button>
            <p> {internals.count} </p>
            <button onClick={$(increment(internals))}>+1</button>
        </>
    );
});

Find more examples in ./src/examples.