-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release v1.2.1
- Loading branch information
Showing
23 changed files
with
315 additions
and
174 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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ on: | |
branches: | ||
- master | ||
pull_request: | ||
brenches: | ||
branches: | ||
- '^bench' | ||
|
||
jobs: | ||
|
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ coverage/ | |
node_modules/ | ||
examples/test | ||
.eslintcache | ||
*.lock |
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,20 +1,15 @@ | ||
{ | ||
"version": "1.0.0", | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "1.7.0", | ||
"npmClient": "ayarn", | ||
"useWorkspaces": true, | ||
"command": { | ||
"bootstrap": { | ||
"npmClientArgs": [ | ||
"--no-package-lock" | ||
] | ||
}, | ||
"publish": { | ||
"skipGit": true, | ||
"allowBranch": "master", | ||
"ignoreChanges": [ | ||
"*.md" | ||
] | ||
"npmClientArgs": ["--no-lockfile"] | ||
} | ||
} | ||
}, | ||
"packages": [ | ||
"packages/*", | ||
"scripts/bench" | ||
] | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## CHANGELOG | ||
|
||
### 1.2.1 | ||
|
||
- refactor: change output result format, avoid mixing `IIFE` and `CJS` | ||
- chore: avoid throw error when update unmounted component | ||
- fix: add error message to `getDerivedStateFromError` hook |
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,5 +1,5 @@ | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./dist/rax.min.js'); | ||
} else { | ||
module.exports = require('./lib/index.js'); | ||
module.exports = require('./dist/rax.js'); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* @jsx createElement */ | ||
|
||
import createElement from '../createElement'; | ||
import Component from '../vdom/component'; | ||
import render from '../render'; | ||
import Host from '../vdom/host'; | ||
import ServerDriver from 'driver-server'; | ||
import { useState, useEffect } from '../hooks'; | ||
|
||
describe('update unmounted component', () => { | ||
function createNodeElement(tagName) { | ||
return { | ||
nodeType: 1, | ||
tagName: tagName.toUpperCase(), | ||
attributes: {}, | ||
style: {}, | ||
childNodes: [], | ||
parentNode: null | ||
}; | ||
} | ||
|
||
beforeEach(function() { | ||
Host.driver = ServerDriver; | ||
jest.useFakeTimers(); | ||
}); | ||
|
||
afterEach(function() { | ||
Host.driver = null; | ||
jest.useRealTimers(); | ||
}); | ||
|
||
it('should warn about class component', () => { | ||
const container = createNodeElement('div'); | ||
let destroyChild; | ||
|
||
class Child extends Component { | ||
state = { | ||
name: 'hello' | ||
} | ||
componentDidMount() { | ||
setTimeout(() => { | ||
this.setState({ | ||
name: 'work' | ||
}); | ||
}, 1000); | ||
} | ||
render() { | ||
return <div>{this.state.name}</div>; | ||
} | ||
} | ||
|
||
class App extends Component { | ||
state = { | ||
showChild: true | ||
} | ||
componentDidMount() { | ||
destroyChild = () => { | ||
this.setState({ | ||
showChild: false | ||
}); | ||
}; | ||
} | ||
render() { | ||
return (<div> | ||
{ this.state.showChild ? <Child /> : null } | ||
</div>); | ||
} | ||
} | ||
|
||
expect(() => { | ||
render(<App />, container); | ||
destroyChild(); | ||
jest.runAllTimers(); | ||
}).toWarnDev("Warning: Can't perform a Rax state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.", { withoutStack: true }); | ||
}); | ||
|
||
it('should warn about function component', () => { | ||
const container = createNodeElement('div'); | ||
let destroyChild; | ||
|
||
function Child() { | ||
const [name, setName] = useState('hello'); | ||
useEffect(() => { | ||
setTimeout(() => { | ||
setName('world'); | ||
}, 1000); | ||
}, []); | ||
return <div>{name}</div>; | ||
} | ||
|
||
class App extends Component { | ||
state = { | ||
showChild: true | ||
} | ||
componentDidMount() { | ||
destroyChild = () => { | ||
this.setState({ | ||
showChild: false | ||
}); | ||
}; | ||
} | ||
render() { | ||
return (<div> | ||
{ this.state.showChild ? <Child /> : null } | ||
</div>); | ||
} | ||
} | ||
|
||
expect(() => { | ||
render(<App />, container); | ||
destroyChild(); | ||
jest.runAllTimers(); | ||
}).toWarnDev("Warning: Can't perform a Rax state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.", { withoutStack: true }); | ||
}); | ||
}); |
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
Oops, something went wrong.