+1
-1
| { | ||
| "name": "hyperwrap", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "Makes React simple and functional", | ||
@@ -5,0 +5,0 @@ "main": "index.tsx", |
+18
-18
@@ -63,5 +63,2 @@ # Meet hyperwrap | ||
| interface Props { | ||
| state?: State; | ||
| } | ||
| export const Home = () => { | ||
@@ -94,10 +91,11 @@ | ||
| const props = { | ||
| state: getState() | ||
| } | ||
| export const Home = ( | ||
| {state, actions}: Props = { | ||
| state: getState() | ||
| } | ||
| ) => { | ||
| const _state = state || getState(); | ||
| export const Home = ({state}: Props = props) => { | ||
| const _state = state || props.state; | ||
| const changeThing = (e: any, thing: string) => { updateState('thing', thing); }; | ||
| const changeThing = (e: any, thing: string) => { updateState('thing', thing); }; | ||
| return ( | ||
@@ -113,3 +111,3 @@ <div> | ||
| > Note the use of _state. We do this because typescript thinks that state may be undefined. `const _state = state || props.state` ensures that _state is definately not undefined. | ||
| > Note the use of _state. We do this because typescript thinks that state may be undefined. `const _state = state || getState()` ensures that typescript knows that _state is definately not undefined. | ||
@@ -153,12 +151,14 @@ # Update State | ||
| const props = { | ||
| state: getState(), | ||
| actions: { | ||
| changeThing | ||
| } | ||
| const actionsCollection = { | ||
| changeThing: changeThing | ||
| } | ||
| export const Home = ({state, actions}: Props = props) => { | ||
| const _state = state || props.state; | ||
| const _actions = actions || props.actions; | ||
| export const Home = ( | ||
| {state, actions}: Props = { | ||
| state: getState(), | ||
| actions: actionsCollection | ||
| } | ||
| ) => { | ||
| const _state = state || getState(); | ||
| const _actions = actions || actionsCollection; | ||
| return ( | ||
@@ -165,0 +165,0 @@ <div> |
5615
0.61%