feat: @avocado/react

This commit is contained in:
cha0s 2021-03-23 13:42:35 -05:00
parent 3385daf8d8
commit d6bb894f49
6 changed files with 6945 additions and 0 deletions

7
packages/react/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
**/*.js
**/*.map
!/.*
!/postcss.config.js
!/webpack.config.js
!src/**/*.js
!/test/**/*.js

View File

@ -0,0 +1,25 @@
{
"version": "1.0.0",
"main": "index.js",
"scripts": {
"build": "latus-build",
"clean": "latus-build clean",
"fp": "latus-build forcepublish",
"lint": "latus-build lint",
"test": "latus-build test"
},
"files": [
"index.js",
"index.js.map",
"test.js",
"test.js.map"
],
"dependencies": {
"@latus/core": "^2.0.0",
"@latus/react": "^2.0.0"
},
"devDependencies": {
"@latus/build": "1.x"
},
"name": "@avocado/react"
}

View File

@ -0,0 +1,14 @@
import {useCallback, useEvent, useState} from '@latus/react';
export default function usePropertyChange(object, property, defaultValue) {
const [value, setValue] = useState(defaultValue);
useEvent(
object,
`${property}Changed`,
useCallback(() => {
const newValue = object[property];
setValue(newValue);
}, [object, property]),
);
return value;
}

View File

@ -0,0 +1,2 @@
// eslint-disable-next-line import/prefer-default-export
export {default as usePropertyChange} from './hooks/use-property-change';

View File

@ -0,0 +1,5 @@
import {expect} from 'chai';
it('exists', () => {
expect(true).to.be.true;
});

6892
packages/react/yarn.lock Normal file

File diff suppressed because it is too large Load Diff