New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

basicelement

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basicelement

The Simplest abstraction over HTMLElement adding on reactive state and nothing else. Less than 1kb.

latest
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

BasicElement

The Simplest abstraction over HTMLElement adding on reactive state and nothing else. Less than 1kb.

CDN Link: https://res.cloudinary.com/dithdroai/raw/upload/v1609690131/libraries/basic_p6rzbt.js (11kb)

CDN Link (ES 6 MODULE VERSION): https://res.cloudinary.com/dithdroai/raw/upload/v1609690120/libraries/basicmodule_zkycnv.js (13 kb)

NPM npx create-basicelement-app projectName or to build a custom build ```npm install basicelement`

Creating a Component

class TestTest extends BasicElement {
    constructor() {
        super({ hello: 'hello' });
    }
    render(state, props) {
        return `<h1>${state.hello}</h1>
            <h2>${props.user}</h2>`;
    }
}

BasicElement.tag('test-test', TestTest);

Using the Component in your HTML

<test-test user="james"></test-test>
<button
    onclick="document.querySelector('test-test').setState({hello: 'cheese'})"
>
    Click Me
</button>

Two rules in constructing a new components:

  • Pass the initial state to super() in the constructor (defaults to an empty object)
  • define a render function that returns your template string
  • for events that need to occur after render, there is also a postRender(state, props) function you can define for that purpose

FAQs

Package last updated on 03 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts