An open API service indexing awesome lists of open source software.

https://github.com/dperrymorrow/mini-reactive

a reactive component lib in under 45 lines of JS
https://github.com/dperrymorrow/mini-reactive

Last synced: about 1 year ago
JSON representation

a reactive component lib in under 45 lines of JS

Awesome Lists containing this project

README

          

# mini-reactive

a reactive component lib in under 80 lines of JS!

- [Working example here](https://dperrymorrow.github.io/mini-reactive/)
- [Example component](https://github.com/dperrymorrow/mini-reactive/blob/main/Todos.js)

## Example Component

```javascript
import Component from "./lib/Component.js";

export default class MyComponent extends Component {
constructor() {
super(...arguments);
this.state = this.useState({
name: "Dave",
});
}

updateTitle(ev) {
this.state.title = ev.target.value;
}

render() {
return `

${this.state.title}


`;
}
}
```

## Example Usage

```html

import App from "./MyComponent.js";

const $root = document.getElementById("app");
$root.innerHTML = new App($root).render();

```

## To run the example here

1. clone this repo
1. cd into directory
1. `npm install`
1. `npm run dev`
1. go to localhost:8000 in your browser