Skip to content

thani-sh/demo-react-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example 1

const Canvas = () => <>
    <Rectangle x="100" y="100" width="100" height="100" color="red" />
    <Rectangle x="225" y="125" width="50" height="50" color="red" />
</>;

Example 2

class Canvas extends React.Component {
    constructor(...args) {
        super(...args);
        this.state = { x: 100, t: Date.now() };
        this.animate();
    }

    animate() {
        requestAnimationFrame(() => {
            const d = Math.PI * (Date.now() - this.state.t) / 1000;
            const x = 200 + 100 * Math.sin(d);
            this.setState({ x });
            this.animate();
        });
    }

    render() {
        const x = this.state.x;
        return <Rectangle x={x} y={100} width={100} height={100} color="red" />;
    }
}

About

Demo code for presentation done at Colombo JS Meetup about react renderers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published