-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): fix react component update not effect (#6656)
* refactor: fix demo types * fix(react): fix react component update not effect * chore: config react test env * test: add test case * chore: update version
- Loading branch information
Showing
11 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/g6-extension-react/__tests__/unit/attribute-changed-callback.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ReactNode } from '../../src'; | ||
|
||
it('attribute changed callback', () => { | ||
const oldComponent = () => <div>test</div>; | ||
const node = new ReactNode({ | ||
style: { | ||
component: oldComponent, | ||
}, | ||
}); | ||
Object.assign(node, { | ||
isConnected: true, | ||
ownerDocument: { | ||
defaultView: { | ||
dispatchEvent: () => {}, | ||
}, | ||
}, | ||
}); | ||
|
||
const spy = jest.spyOn(node, 'attributeChangedCallback'); | ||
|
||
const component = () => <div>test1</div>; | ||
|
||
try { | ||
node.update({ component }); | ||
} catch (e) { | ||
// ignore | ||
} | ||
|
||
expect(spy).toHaveBeenCalled(); | ||
expect(spy).toHaveBeenLastCalledWith('component', oldComponent, component, undefined, undefined); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
const esm = ['internmap', 'd3-*', 'lodash-es', 'chalk'].map((d) => `_${d}|${d}`).join('|'); | ||
|
||
module.exports = { | ||
transform: { | ||
'^.+\\.[tj]s$': ['@swc/jest'], | ||
'^.+\\.[tj]sx?$': [ | ||
'@swc/jest', | ||
{ | ||
jsc: { | ||
parser: { | ||
syntax: 'typescript', | ||
decorators: true, | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
testRegex: '(/__tests__/.*\\.(test|spec))\\.(ts|tsx|js)$', | ||
collectCoverageFrom: ['src/**/*.ts'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], | ||
transformIgnorePatterns: [`<rootDir>/node_modules/.pnpm/(?!(${esm}))`], | ||
moduleNameMapper: { | ||
'@antv/g6': '<rootDir>/../g6/src', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const version = '5.0.37'; | ||
export const version = '5.0.38'; |