Skip to content

Commit

Permalink
Merge branch 'master' into feature/remove-connectadvanced
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Sep 4, 2021
2 parents c7c2f0c + a3503c1 commit d98c91c
Show file tree
Hide file tree
Showing 19 changed files with 2,721 additions and 2,468 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [master, typescript-port]
pull_request:
branches: [master, typescript-port]
workflow_dispatch:

jobs:
build:
Expand Down
14 changes: 5 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
const { defaults: tsjPreset } = require('ts-jest/presets')

const defaults = {
coverageDirectory: './coverage/',
collectCoverage: true,
testURL: 'http://localhost',
}
const testFolderPath = (folderName) => `<rootDir>/test/${folderName}/**/*.js`

const NORMAL_TEST_FOLDERS = ['components', 'hooks', 'integration', 'utils']

const standardConfig = {
...defaults,
displayName: 'ReactDOM',
testMatch: NORMAL_TEST_FOLDERS.map(testFolderPath),
}

const tsTestFolderPath = (folderName) =>
`<rootDir>/test/${folderName}/**/*.{ts,tsx}`

Expand All @@ -26,13 +21,14 @@ const tsStandardConfig = {
const rnConfig = {
...defaults,
displayName: 'React Native',
testMatch: [testFolderPath('react-native')],
testMatch: [tsTestFolderPath('react-native')],
preset: 'react-native',
transform: {
'^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
...tsjPreset.transform,
},
}

module.exports = {
projects: [tsStandardConfig, standardConfig, rnConfig],
projects: [tsStandardConfig, rnConfig],
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@
"@testing-library/react": "^12.0.0",
"@testing-library/react-hooks": "^3.4.2",
"@testing-library/react-native": "^7.1.0",
"@types/create-react-class": "^15.6.3",
"@types/object-assign": "^4.0.30",
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"@types/react-is": "^17.0.1",
"@types/react-native": "^0.64.12",
"@types/react-redux": "^7.1.18",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/useSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ function useSelectorWithStoreAndSubscription<TStoreState, TSelectedState>(
function checkForUpdates() {
try {
const newStoreState = store.getState()
// Avoid calling selector multiple times if the store's state has not changed
if (newStoreState === latestStoreState.current) {
return
}

const newSelectedState = latestSelector.current!(newStoreState)

if (equalityFn(newSelectedState, latestSelectedState.current)) {
Expand Down
Loading

0 comments on commit d98c91c

Please sign in to comment.