constate
Advanced tools
Comparing version 1.1.1 to 1.2.0
196
CHANGELOG.md
@@ -1,212 +0,34 @@ | ||
# Change Log | ||
# Changelog | ||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
## [1.1.1](https://github.com/diegohaz/constate/compare/v1.1.0...v1.1.1) (2019-04-14) | ||
## [1.2.0](https://github.com/diegohaz/constate/compare/v1.1.1...v1.2.0) (2019-06-29) | ||
### Bug Fixes | ||
* Fix React peer dependency range ([7132e3d](https://github.com/diegohaz/constate/commit/7132e3d)) | ||
# [1.1.0](https://github.com/diegohaz/constate/compare/v1.0.0...v1.1.0) (2019-04-14) | ||
### Features | ||
* Return a hook from the createContainer method ([#78](https://github.com/diegohaz/constate/issues/78)) ([8de6eb6](https://github.com/diegohaz/constate/commit/8de6eb6)), closes [#77](https://github.com/diegohaz/constate/issues/77) | ||
* Set displayName of Context and Provider ([#79](https://github.com/diegohaz/constate/issues/79)) ([#80](https://github.com/diegohaz/constate/issues/80)) ([fc6595f](https://github.com/diegohaz/constate/commit/fc6595f)) | ||
<a name="1.0.0"></a> | ||
# [1.0.0](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.7...v1.0.0) (2019-02-06) | ||
## [1.1.1](https://github.com/diegohaz/constate/compare/v1.1.0...v1.1.1) (2019-04-14) | ||
<a name="1.0.0-alpha.7"></a> | ||
# [1.0.0-alpha.7](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2019-01-17) | ||
### Bug Fixes | ||
* Use `Proxy` only when available and in `development` ([6745b35](https://github.com/diegohaz/constate/commit/6745b35)), closes [#65](https://github.com/diegohaz/constate/issues/65) | ||
* Fix React peer dependency range ([7132e3d](https://github.com/diegohaz/constate/commit/7132e3d)) | ||
<a name="1.0.0-alpha.6"></a> | ||
# [1.0.0-alpha.6](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2018-12-14) | ||
# [1.1.0](https://github.com/diegohaz/constate/compare/v1.0.0...v1.1.0) (2019-04-14) | ||
### Bug Fixes | ||
* Ensure lazy initialization happens only once per context key ([#55](https://github.com/diegohaz/constate/issues/55)) ([0cfc10f](https://github.com/diegohaz/constate/commit/0cfc10f)) | ||
### Features | ||
* `createContainer` ([#58](https://github.com/diegohaz/constate/issues/58)) ([bb90895](https://github.com/diegohaz/constate/commit/bb90895)) | ||
* Support `devtools` string on `Provider` ([#56](https://github.com/diegohaz/constate/issues/56)) ([939ba36](https://github.com/diegohaz/constate/commit/939ba36)) | ||
* Return a hook from the createContainer method ([#78](https://github.com/diegohaz/constate/issues/78)) ([8de6eb6](https://github.com/diegohaz/constate/commit/8de6eb6)), closes [#77](https://github.com/diegohaz/constate/issues/77) | ||
### BREAKING CHANGES | ||
* Removed `useContextState` and other hooks. They've been replaced by `createContainer`. | ||
# [1.0.0](https://github.com/diegohaz/constate/compare/v0.9.0...v1.0.0) (2019-02-06) | ||
<a name="1.0.0-alpha.5"></a> | ||
# [1.0.0-alpha.5](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2018-12-03) | ||
### Bug Fixes | ||
* Fix `useContextState` not supporting lazy initialization ([#54](https://github.com/diegohaz/constate/issues/54)) ([059216d](https://github.com/diegohaz/constate/commit/059216d)), closes [#53](https://github.com/diegohaz/constate/issues/53) | ||
### Code Refactoring | ||
* Replace `useMutationEffect` by `useLayoutEffect` ([4dada0f](https://github.com/diegohaz/constate/commit/4dada0f)) | ||
### BREAKING CHANGES | ||
* `useContextMutationEffect` has been removed. `React.useMutationEffect` will be removed from React hooks, so this is just to reflect that (see https://github.com/facebook/react/pull/14336). | ||
<a name="1.0.0-alpha.4"></a> | ||
# [1.0.0-alpha.4](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2018-11-27) | ||
### Features | ||
* Add new `useContextKey` hook ([e0d8cd8](https://github.com/diegohaz/constate/commit/e0d8cd8)) | ||
### BREAKING CHANGES | ||
* Removed `unstable_` prefix from `useContextEffect` hooks. They're no longer using React internal stuff, but now they require `useContextKey`. See [docs](https://github.com/diegohaz/constate#usecontexteffect). | ||
<a name="1.0.0-alpha.3"></a> | ||
# [1.0.0-alpha.3](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2018-11-25) | ||
### Bug Fixes | ||
* Accept arguments other than objects in `createContext` ([93327a3](https://github.com/diegohaz/constate/commit/93327a3)) | ||
<a name="1.0.0-alpha.2"></a> | ||
# [1.0.0-alpha.2](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2018-11-22) | ||
### Bug Fixes | ||
* Fix Redux DevTools creating unnecessary entries ([7162ad2](https://github.com/diegohaz/constate/commit/7162ad2)) | ||
* Fix usage of `useContext(Context)` ([3ff531a](https://github.com/diegohaz/constate/commit/3ff531a)) | ||
* Make `initialAction` on `useContextReducer` synchronous on render ([bde4b3c](https://github.com/diegohaz/constate/commit/bde4b3c)) | ||
### BREAKING CHANGES | ||
* `createContext` doesn't accept a `name` argument anymore. | ||
<a name="1.0.0-alpha.1"></a> | ||
# [1.0.0-alpha.1](https://github.com/diegohaz/constate/compare/v1.0.0-alpha.0...v1.0.0-alpha.1) (2018-11-21) | ||
### Bug Fixes | ||
* Fix `useContextEffect` when it's used more than once ([3a28d2d](https://github.com/diegohaz/constate/commit/3a28d2d)) | ||
### BREAKING CHANGES | ||
* Renamed `useContextEffect` and its variations to `unstable_useContextEffect` | ||
<a name="1.0.0-alpha.0"></a> | ||
# [1.0.0-alpha.0](https://github.com/diegohaz/constate/compare/v0.9.0...v1.0.0-alpha.0) (2018-11-21) | ||
### Features | ||
* Hooks ([#51](https://github.com/diegohaz/constate/issues/51)) ([10dd41d](https://github.com/diegohaz/constate/commit/10dd41d)), closes [#48](https://github.com/diegohaz/constate/issues/48) | ||
<a name="0.9.0"></a> | ||
# [0.9.0](https://github.com/diegohaz/constate/compare/v0.8.2...v0.9.0) (2018-10-03) | ||
### Features | ||
* Add `pure` prop to `Container` ([#44](https://github.com/diegohaz/constate/issues/44)) ([262d931](https://github.com/diegohaz/constate/commit/262d931)) | ||
### BREAKING CHANGES | ||
* If you're using TypeScript, `ActionMap` no longer accepts the short version of action (i.e. returning an object directly). | ||
<a name="0.8.2"></a> | ||
## [0.8.2](https://github.com/diegohaz/constate/compare/v0.8.1...v0.8.2) (2018-09-10) | ||
### Features | ||
* **typescript:** Export `ProviderProps` type from Provider component ([#41](https://github.com/diegohaz/constate/issues/41)) ([ab132f6](https://github.com/diegohaz/constate/commit/ab132f6)) | ||
<a name="0.8.1"></a> | ||
## [0.8.1](https://github.com/diegohaz/constate/compare/v0.8.0...v0.8.1) (2018-08-29) | ||
### Bug Fixes | ||
* Make Container work on server side ([#40](https://github.com/diegohaz/constate/issues/40)) ([9ed0e7b](https://github.com/diegohaz/constate/commit/9ed0e7b)), closes [#38](https://github.com/diegohaz/constate/issues/38) | ||
<a name="0.8.0"></a> | ||
# [0.8.0](https://github.com/diegohaz/constate/compare/v0.7.2...v0.8.0) (2018-08-23) | ||
### Features | ||
* Rewrite the library in TypeScript ([#36](https://github.com/diegohaz/constate/issues/36)) ([de1cd09](https://github.com/diegohaz/constate/commit/de1cd09)) | ||
### BREAKING CHANGES | ||
* Experimental `mount` module has been removed. | ||
<a name="0.7.2"></a> | ||
## [0.7.2](https://github.com/diegohaz/constate/compare/v0.7.1...v0.7.2) (2018-07-20) | ||
### Bug Fixes | ||
* onUpdate should be called if shouldUpdate returns true ([446c871](https://github.com/diegohaz/constate/commit/446c871)) | ||
<a name="0.7.1"></a> | ||
## [0.7.1](https://github.com/diegohaz/constate/compare/v0.7.0...v0.7.1) (2018-07-10) | ||
### Features | ||
* Add shouldUpdate ([#32](https://github.com/diegohaz/constate/issues/32)) ([88d49f8](https://github.com/diegohaz/constate/commit/88d49f8)) | ||
First official release. |
@@ -34,2 +34,7 @@ 'use strict'; | ||
if (useValue.name) { | ||
Context.displayName = useValue.name + ".Context"; | ||
Provider.displayName = useValue.name + ".Provider"; | ||
} | ||
var useContext = function useContext() { | ||
@@ -36,0 +41,0 @@ return React.useContext(Context); |
@@ -1,2 +0,2 @@ | ||
import { createContext, useContext, useMemo, createElement } from 'react'; | ||
import { createContext, useMemo, createElement, useContext } from 'react'; | ||
@@ -30,2 +30,7 @@ function warnNoProvider() { | ||
if (useValue.name) { | ||
Context.displayName = useValue.name + ".Context"; | ||
Provider.displayName = useValue.name + ".Provider"; | ||
} | ||
var useContext$1 = function useContext$1() { | ||
@@ -32,0 +37,0 @@ return useContext(Context); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).constate={},e.React)}(this,function(e,i){"use strict";var t={};e.default=function(r,o){var u=i.createContext(t),e=function(){return i.useContext(u)};return e.Context=u,e.Provider=function(e){var t=r(e),n=o?i.useMemo(function(){return t},o(t)):t;return i.createElement(u.Provider,{value:n},e.children)},e},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).constate={},e.React)}(this,function(e,i){"use strict";var n={};e.default=function(r,o){var a=i.createContext(n),e=function(e){var t=r(e),n=o?i.useMemo(function(){return t},o(t)):t;return i.createElement(a.Provider,{value:n},e.children)};r.name&&(a.displayName=r.name+".Context",e.displayName=r.name+".Provider");var t=function(){return i.useContext(a)};return t.Context=a,t.Provider=e,t},Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -5,6 +5,4 @@ import * as React from "react"; | ||
Context: React.Context<V>; | ||
Provider: (props: { | ||
children?: React.ReactNode; | ||
} & P) => JSX.Element; | ||
Provider: React.FunctionComponent<P>; | ||
}; | ||
export default createUseContext; |
{ | ||
"name": "constate", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Yet another React state management library that lets you work with local state and scale up to global state with ease", | ||
@@ -24,3 +24,3 @@ "license": "MIT", | ||
"coverage": "npm test -- --coverage", | ||
"postcoverage": "opn coverage/lcov-report/index.html", | ||
"postcoverage": "open-cli coverage/lcov-report/index.html", | ||
"type-check": "tsc --noEmit", | ||
@@ -55,26 +55,27 @@ "lint": "eslint . --ext js,ts,tsx", | ||
"devDependencies": { | ||
"@babel/cli": "7.4.3", | ||
"@babel/core": "7.4.3", | ||
"@babel/preset-env": "7.4.3", | ||
"@babel/cli": "7.4.4", | ||
"@babel/core": "7.4.5", | ||
"@babel/preset-env": "7.4.5", | ||
"@babel/preset-react": "7.0.0", | ||
"@babel/preset-typescript": "7.3.3", | ||
"@types/jest": "24.0.11", | ||
"@types/prop-types": "15.7.0", | ||
"@types/react": "16.8.13", | ||
"@typescript-eslint/eslint-plugin": "1.6.0", | ||
"@typescript-eslint/parser": "1.6.0", | ||
"@testing-library/react": "8.0.1", | ||
"@types/jest": "24.0.13", | ||
"@types/prop-types": "15.7.1", | ||
"@types/react": "16.8.19", | ||
"@typescript-eslint/eslint-plugin": "1.9.0", | ||
"@typescript-eslint/parser": "1.9.0", | ||
"babel-eslint": "10.0.1", | ||
"babel-jest": "24.7.1", | ||
"babel-jest": "24.8.0", | ||
"eslint": "5.16.0", | ||
"eslint-config-airbnb": "17.1.0", | ||
"eslint-config-prettier": "4.1.0", | ||
"eslint-plugin-import": "2.17.1", | ||
"eslint-config-prettier": "4.3.0", | ||
"eslint-plugin-import": "2.17.3", | ||
"eslint-plugin-jsx-a11y": "6.2.1", | ||
"eslint-plugin-prettier": "3.0.1", | ||
"eslint-plugin-react": "7.12.4", | ||
"husky": "1.3.1", | ||
"jest": "24.7.1", | ||
"lint-staged": "8.1.5", | ||
"opn-cli": "4.1.0", | ||
"prettier": "1.17.0", | ||
"eslint-plugin-prettier": "3.1.0", | ||
"eslint-plugin-react": "7.13.0", | ||
"husky": "2.4.0", | ||
"jest": "24.8.0", | ||
"lint-staged": "8.2.0", | ||
"open-cli": "5.0.0", | ||
"prettier": "1.18.0", | ||
"raf": "3.4.1", | ||
@@ -84,13 +85,12 @@ "react": "16.8.6", | ||
"react-test-renderer": "16.8.6", | ||
"react-testing-library": "6.1.2", | ||
"rimraf": "2.6.3", | ||
"rollup": "1.10.0", | ||
"rollup": "1.14.3", | ||
"rollup-plugin-babel": "4.3.2", | ||
"rollup-plugin-commonjs": "9.3.4", | ||
"rollup-plugin-commonjs": "10.0.0", | ||
"rollup-plugin-ignore": "1.0.5", | ||
"rollup-plugin-node-resolve": "4.2.3", | ||
"rollup-plugin-node-resolve": "5.0.1", | ||
"rollup-plugin-replace": "2.2.0", | ||
"rollup-plugin-uglify": "6.0.2", | ||
"standard-version": "5.0.2", | ||
"typescript": "3.4.3" | ||
"standard-version": "6.0.1", | ||
"typescript": "3.5.1" | ||
}, | ||
@@ -97,0 +97,0 @@ "peerDependencies": { |
@@ -38,3 +38,3 @@ <p align="center"> | ||
```jsx | ||
import React, { useState, useContext } from "react"; | ||
import React, { useState } from "react"; | ||
import createUseContext from "constate"; | ||
@@ -49,9 +49,7 @@ | ||
// 2️⃣ When you need to share your state, simply wrap your hook | ||
// with the createUseContext factory, like so: | ||
// 2️⃣ Wrap your hook with the createUseContext factory | ||
const useCounterContext = createUseContext(useCounter); | ||
function Button() { | ||
// 3️⃣ Use container context instead of custom hook | ||
// const { increment } = useCounter(); | ||
// 3️⃣ Use context instead of custom hook | ||
const { increment } = useCounterContext() | ||
@@ -62,4 +60,3 @@ return <button onClick={increment}>+</button>; | ||
function Count() { | ||
// 4️⃣ Use container context in other components | ||
// const { count } = useCounter(); | ||
// 4️⃣ Use context in other components | ||
const { count } = useCounterContext() | ||
@@ -70,3 +67,3 @@ return <span>{count}</span>; | ||
function App() { | ||
// 5️⃣ Wrap your components with provider | ||
// 5️⃣ Wrap your components with Provider | ||
return ( | ||
@@ -139,4 +136,2 @@ <useCounterContext.Provider> | ||
```jsx | ||
import React, { useContext } from "react"; | ||
function Counter() { | ||
@@ -143,0 +138,0 @@ const count = useCounterContext(); |
Sorry, the diff of this file is not supported yet
119
22591
181