diff --git a/.size-snapshot.json b/.size-snapshot.json index d1ed533..949b600 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,20 +1,20 @@ { "dist/index.js": { - "bundled": 96409, - "minified": 46532, - "gzipped": 12274 + "bundled": 96393, + "minified": 46534, + "gzipped": 12272 }, "dist/index.es.js": { - "bundled": 95844, - "minified": 46040, - "gzipped": 12164, + "bundled": 95828, + "minified": 46042, + "gzipped": 12160, "treeshaked": { "rollup": { "code": 78, "import_statements": 21 }, "webpack": { - "code": 11105 + "code": 11109 } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cfa42f..e5aaf31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.0.0-beta.22 + +- Fixed an issue where `useRowState` would crash due to invalid initial state attempting to spread into the new state + ## 7.0.0-beta.21 - Removed deprecated `defaultState` export diff --git a/README.md b/README.md index e3d8ff1..99d426a 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ This library is being built and maintained by me, @tannerlinsley and I am always #### I'm still using v6, what should I do? -v6 is a great library and is still the default install for `react-table`, however, I do not intend on offering any long-term support for it. If you intend to keep using v6, I recommend maintaining your own fork of the library and keeping it up to date for your version of React. +v6 is a great library and while it is still available for use, I do not intend on offering any long-term support for it. If you intend to keep using v6, I recommend maintaining your own fork of the library and keeping it up to date for your version of React. #### Where are the docs for the older v6 version? diff --git a/package.json b/package.json index 53864c0..41221aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-table", - "version": "7.0.0-beta.21", + "version": "7.0.0-beta.22", "description": "A fast, lightweight, opinionated table and datagrid built on React", "license": "MIT", "homepage": "https://github.com/tannerlinsley/react-table#readme", diff --git a/src/plugin-hooks/useRowState.js b/src/plugin-hooks/useRowState.js index 5f8a94e..bcc4f95 100644 --- a/src/plugin-hooks/useRowState.js +++ b/src/plugin-hooks/useRowState.js @@ -36,7 +36,7 @@ reducerHandlers[pluginName] = (state, action) => { ...state, rowState: { ...state.rowState, - [pathKey]: functionalUpdate(value, state.rowState[pathKey]), + [pathKey]: functionalUpdate(value, state.rowState[pathKey] || {}), }, } } @@ -71,7 +71,7 @@ function useMain(instance) { ) const setCellState = React.useCallback( - (rowPath, columnId, updater) => { + (rowPath, columnId, value) => { return setRowState( rowPath, old => { @@ -79,10 +79,10 @@ function useMain(instance) { ...old, cellState: { ...old.cellState, - [columnId]: - typeof updater === 'function' - ? updater(old.cellState[columnId]) - : updater, + [columnId]: functionalUpdate( + value, + old.cellState[columnId] || {} + ), }, } },