Skip to content
This repository has been archived by the owner. It is now read-only.

laurencedorman/preact-classless-component

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Preact Classless Component

npm travis Dependency Status devDependency Status

If you use the Preact library, but don't want to use the class syntax because you've read articles by Eric Elliott and others that have lead you to favour object composition over class inheritance, then this utility is for you.

Installation

$ npm install --save preact-classless-component

Usage

/* ES6 Modules */

import createComponent from 'preact-classless-component';

/* CommonJS */

const createComponent = require('preact-classless-component');

const Component = createComponent({
	render(props, state) {
		return (
			<div>
				Hello world!
			</div>
		);
	}
});

Acknowledgments

Thanks to Jason Miller for his help on debugging this function.

License

MIT

About

A utility method to create preact components without using class keyword

Resources

License

Stars

Watchers

Forks

Packages

No packages published