Skip to content
A utility method to create preact components without using class keyword
JavaScript
Branch: master
Clone or download
laurencedorman Merge pull request #9 from laurencedorman/dependabot/npm_and_yarn/lod…
…ash-4.17.14

build(deps): bump lodash from 4.17.11 to 4.17.14
Latest commit 2b44ac7 Jul 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
.editorconfig add: basic functionality Apr 27, 2016
.gitignore update distribution files May 3, 2016
.npmignore remove: npm-debug Apr 27, 2016
.travis.yml npm audit: remove jscs, mocha, chai Apr 29, 2019
LICENSE Initial commit Apr 27, 2016
README.md update: readme badges Feb 23, 2018
index.js npm audit: remove jscs, mocha, chai Apr 29, 2019
package-lock.json
package.json 2.0.0 Apr 29, 2019
test.js npm audit: remove jscs, mocha, chai Apr 29, 2019

README.md

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

You can’t perform that action at this time.