just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo.
| /** | |
| * Copyright 2018 Google LLC | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
| * use this file except in compliance with the License. You may obtain a copy of | |
| * the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| /** | |
| * Copyright 2018 Google Inc. All Rights Reserved. | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and |
| /* | |
| * Stateless Classful Components | |
| * | |
| * - no access to setState() or forceUpdate() | |
| * - render is still just: props => Element | |
| */ | |
| class Events { | |
| componentDidMount() { | |
| for (let i in this.props) { |
| /** Usage: | |
| * const MyView = unrecycle(props => { | |
| * // this is normally a no-go and creates leaking styles, but it won't with unrecycle(): | |
| * <input ref={ c => c && c.style.background='red' } /> | |
| * }) | |
| */ | |
| export default function unrecycle(Component) { | |
| return function Unrecycle(props, context) { | |
| this.componentWillUnmount = dontRecycle; | |
| return Component.call(this, props, context); |
just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo.
| import { createElement, cloneElement, Component } from 'react' | |
| import { render, findDOMNode } from 'react-dom' | |
| Object.defineProperty(Component.prototype, 'base', { | |
| get() { return findDOMNode(this) } | |
| }) | |
| export { createElement, createElement as h, cloneElement, Component } | |
| export { render } |
| [{"_id":"5b881b2beccf112e7fa48589","index":0,"guid":"8246c6fb-7cba-4cc6-b1d2-ff22f4a1ae91","isActive":true,"balance":"$3,618.71","picture":"http://placehold.it/32x32","age":32,"eyeColor":"blue","name":{"first":"Henderson","last":"Ball"},"company":"GEOFORMA","email":"henderson.ball@geoforma.us","phone":"+1 (892) 523-3044","address":"277 Bryant Street, Bawcomville, Oregon, 7682","about":"Lorem et in tempor elit mollit irure enim voluptate sint consequat sint fugiat sint. Aute fugiat dolor ullamco aliqua dolor occaecat. Cillum incididunt tempor mollit officia deserunt eu quis commodo adipisicing enim pariatur quis Lorem. Adipisicing eiusmod do et eiusmod ad ut. Sint ea exercitation nisi officia quis consectetur ad. Enim adipisicing officia veniam enim anim voluptate incididunt laborum irure et officia eu.","registered":"Monday, April 28, 2014 3:31 PM","latitude":"-50.104304","longitude":"87.683747","tags":["consectetur","est","quis","nostrud","cillum"],"range":[0,1,2,3,4,5,6,7,8,9],"friends":[{"id":0,"name":"Bra |
| import preact from 'preact'; | |
| import PropTypes from 'prop-types'; | |
| // installs global prop type checking for app preact components | |
| preact.options.vnode = vnode => { | |
| let Component = vnode.nodeName; | |
| if (Component.propTypes) { | |
| PropTypes.checkPropTypes( | |
| Component.propTypes, | |
| vnode.attributes |
| const { performance } = require('perf_hooks'); | |
| const h1 = (tag, props, children) => ({ tag, props, children }) | |
| const h2 = (tag, props, children) => ({ tag, props, children }) | |
| function serializeProps(props) { | |
| let out = ''; | |
| for (let i in props) out += ` ${i}="${props[i]}"`; | |
| return out; | |
| } |