Skip to content
Permalink
Browse files

Rename useMain and useBeforeDimensions hooks

  • Loading branch information
tannerlinsley committed Dec 2, 2019
1 parent 83f889d commit f9a62731848f3d1c2e140cd385dbed124306dcf6
@@ -1,13 +1,13 @@
{
"dist/index.js": {
"bundled": 96393,
"minified": 46534,
"gzipped": 12272
"bundled": 96601,
"minified": 46726,
"gzipped": 12271
},
"dist/index.es.js": {
"bundled": 95828,
"minified": 46042,
"gzipped": 12160,
"bundled": 96036,
"minified": 46234,
"gzipped": 12155,
"treeshaked": {
"rollup": {
"code": 78,
@@ -1,3 +1,8 @@
## 7.0.0-beta.23

- The internal `useMain` hook has been renamed to `useInstance`
- The internal `useBeforeDimensions` hook has been renamed to `useInstanceBeforeDimensions`

## 7.0.0-beta.22

- Fixed an issue where `useRowState` would crash due to invalid initial state attempting to spread into the new state
@@ -75,7 +75,7 @@ export interface UseTableHooks<D extends object> {
columnsBeforeHeaderGroupsDeps: Array<
(deps: any[], instance: TableInstance<D>) => any[]
>
useMain: Array<(instance: TableInstance<D>) => TableInstance<D>>
useInstance: Array<(instance: TableInstance<D>) => TableInstance<D>>
useRows: Array<
(rows: Array<Row<D>>, instance: TableInstance<D>) => Array<Row<D>>
>
@@ -84,8 +84,8 @@ export const useTable = (props, ...plugins) => {
hooks: {
columnsBeforeHeaderGroups: [],
columnsBeforeHeaderGroupsDeps: [],
useBeforeDimensions: [],
useMain: [],
useInstanceBeforeDimensions: [],
useInstance: [],
useRows: [],
prepareRow: [],
getTableProps: [],
@@ -230,24 +230,24 @@ export const useTable = (props, ...plugins) => {
)

if (process.env.NODE_ENV !== 'production' && debug)
console.time('hooks.useBeforeDimensions')
console.time('hooks.useInstanceBeforeDimensions')
instanceRef.current = applyHooks(
instanceRef.current.hooks.useBeforeDimensions,
instanceRef.current.hooks.useInstanceBeforeDimensions,
instanceRef.current
)
if (process.env.NODE_ENV !== 'production' && debug)
console.timeEnd('hooks.useBeforeDimensions')
console.timeEnd('hooks.useInstanceBeforeDimensions')

calculateDimensions(instanceRef.current)

if (process.env.NODE_ENV !== 'production' && debug)
console.time('hooks.useMain')
console.time('hooks.useInstance')
instanceRef.current = applyHooks(
instanceRef.current.hooks.useMain,
instanceRef.current.hooks.useInstance,
instanceRef.current
)
if (process.env.NODE_ENV !== 'production' && debug)
console.timeEnd('hooks.useMain')
console.timeEnd('hooks.useInstance')

// Each materialized header needs to be assigned a render function and other
// prop getter properties here.
@@ -1,10 +1,10 @@
export const useAbsoluteLayout = hooks => {
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useAbsoluteLayout.pluginName = 'useAbsoluteLayout'

const useMain = instance => {
const useInstance = instance => {
const {
totalColumnsWidth,
hooks: {
@@ -1,10 +1,10 @@
export const useBlockLayout = hooks => {
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useBlockLayout.pluginName = 'useBlockLayout'

const useMain = instance => {
const useInstance = instance => {
const {
totalColumnsWidth,
hooks: { getRowProps, getHeaderGroupProps, getHeaderProps, getCellProps },
@@ -38,7 +38,7 @@ export const useColumnOrder = hooks => {
return [...deps, instance.state.columnOrder]
})
hooks.columnsBeforeHeaderGroups.push(columnsBeforeHeaderGroups)
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useColumnOrder.pluginName = pluginName
@@ -74,7 +74,7 @@ function columnsBeforeHeaderGroups(columns, instance) {
return [...columnsInOrder, ...columnsCopy]
}

function useMain(instance) {
function useInstance(instance) {
const { dispatch } = instance

const setColumnOrder = React.useCallback(
@@ -54,14 +54,14 @@ reducerHandlers[pluginName] = (state, action) => {

export const useExpanded = hooks => {
hooks.getExpandedToggleProps = []
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useExpanded.pluginName = pluginName

const defaultGetResetExpandedDeps = ({ data }) => [data]

function useMain(instance) {
function useInstance(instance) {
const {
debug,
rows,
@@ -109,12 +109,12 @@ reducerHandlers[pluginName] = (state, action) => {
}

export const useFilters = hooks => {
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useFilters.pluginName = pluginName

function useMain(instance) {
function useInstance(instance) {
const {
debug,
rows,
@@ -58,7 +58,7 @@ export const useGroupBy = hooks => {
deps.push(instance.state.groupBy)
return deps
})
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useGroupBy.pluginName = pluginName
@@ -83,7 +83,7 @@ function columnsBeforeHeaderGroups(flatColumns, { state: { groupBy } }) {

const defaultUserAggregations = {}

function useMain(instance) {
function useInstance(instance) {
const {
debug,
rows,
@@ -61,7 +61,7 @@ reducerHandlers[pluginName] = (state, action) => {
}

export const usePagination = hooks => {
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

usePagination.pluginName = pluginName
@@ -72,7 +72,7 @@ const defaultGetResetPageDeps = ({
state: { filters, groupBy, sortBy },
}) => [manualPagination ? null : data, filters, groupBy, sortBy]

function useMain(instance) {
function useInstance(instance) {
const {
rows,
manualPagination,
@@ -80,12 +80,12 @@ reducerHandlers[pluginName] = (state, action) => {
}

export const useResizeColumns = hooks => {
hooks.useBeforeDimensions.push(useBeforeDimensions)
hooks.useInstanceBeforeDimensions.push(useInstanceBeforeDimensions)
}

useResizeColumns.pluginName = pluginName

const useBeforeDimensions = instance => {
const useInstanceBeforeDimensions = instance => {
instance.hooks.getResizerProps = []

const {
@@ -118,7 +118,7 @@ export const useRowSelect = hooks => {
hooks.getToggleRowSelectedProps = []
hooks.getToggleAllRowsSelectedProps = []
hooks.useRows.push(useRows)
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useRowSelect.pluginName = pluginName
@@ -147,7 +147,7 @@ function useRows(rows, instance) {

const defaultGetResetSelectedRowPathsDeps = ({ data }) => [data]

function useMain(instance) {
function useInstance(instance) {
const {
hooks,
manualRowSelectedKey = 'isSelected',
@@ -43,14 +43,14 @@ reducerHandlers[pluginName] = (state, action) => {
}

export const useRowState = hooks => {
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useRowState.pluginName = pluginName

const defaultGetResetRowStateDeps = ({ data }) => [data]

function useMain(instance) {
function useInstance(instance) {
const {
hooks,
initialRowStateAccessor,
@@ -149,12 +149,12 @@ defaultColumn.sortType = 'alphanumeric'
defaultColumn.sortDescFirst = false

export const useSortBy = hooks => {
hooks.useMain.push(useMain)
hooks.useInstance.push(useInstance)
}

useSortBy.pluginName = pluginName

function useMain(instance) {
function useInstance(instance) {
const {
debug,
rows,

0 comments on commit f9a6273

Please sign in to comment.
You can’t perform that action at this time.