react-hooks-global-state
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -21,15 +21,15 @@ /* eslint-env jest */ | ||
}; | ||
const { StateProvider, StateConsumer } = createGlobalState(initialState); | ||
const Counter = () => ( | ||
<StateConsumer name="counter1"> | ||
{(value, update) => ( | ||
<div> | ||
<span>{value}</span> | ||
<button type="button" onClick={() => update(value + 1)}>+1</button> | ||
</div> | ||
)} | ||
</StateConsumer> | ||
); | ||
const { stateItemHooks } = createGlobalState(initialState); | ||
const useCounter1 = stateItemHooks.counter1; | ||
const Counter = () => { | ||
const [value, update] = useCounter1(); | ||
return ( | ||
<div> | ||
<span>{value}</span> | ||
<button type="button" onClick={() => update(value + 1)}>+1</button> | ||
</div> | ||
); | ||
}; | ||
const App = () => ( | ||
<StateProvider> | ||
<div> | ||
<div className="first"> | ||
@@ -41,3 +41,3 @@ <Counter /> | ||
</div> | ||
</StateProvider> | ||
</div> | ||
); | ||
@@ -44,0 +44,0 @@ const wrapper = mount(<App />); |
@@ -5,4 +5,8 @@ # Change Log | ||
## [0.0.2] - 2018-10-30 | ||
### Changed | ||
- Update README | ||
## [0.0.1] - 2018-10-28 | ||
### Added | ||
- Initial experimental release |
{ | ||
"name": "react-hooks-global-state", | ||
"description": "Simple global state for React by Hooks API", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "Daishi Kato", | ||
@@ -57,3 +57,3 @@ "repository": { | ||
"react-dom": "^16.7.0-alpha.0", | ||
"react-use": "^1.2.0", | ||
"react-use": "^3.1.0", | ||
"ts-loader": "^5.2.2", | ||
@@ -60,0 +60,0 @@ "tslint": "^5.11.0", |
@@ -44,6 +44,6 @@ react-hooks-global-state | ||
const App = () => ( | ||
<StateProvider> | ||
<div> | ||
<Counter /> | ||
<Counter /> | ||
</StateProvider> | ||
</div> | ||
); | ||
@@ -63,1 +63,6 @@ ``` | ||
and open <http://localhost:8080> in your web browser. | ||
Blogs | ||
----- | ||
- [TypeScript-aware React hooks for global state](https://medium.com/@dai_shi/typescript-aware-react-hooks-for-global-state-b6e2dfc0e9a7) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67
25230