Commit d9d931cd authored by Shen Chang's avatar Shen Chang

fix(Provider): <Provider> nesting error

parent e95cef41
import React from 'react'; import React from 'react';
import {bindLifecycle} from '../../../es'; import {Provider, KeepAlive} from '../../../es';
@bindLifecycle
class Content extends React.Component { class Content extends React.Component {
componentWillMount() { componentWillMount() {
console.log('A Content componentWillMount'); console.log('A Content componentWillMount');
...@@ -40,7 +39,6 @@ class Content extends React.Component { ...@@ -40,7 +39,6 @@ class Content extends React.Component {
} }
} }
@bindLifecycle
class Test extends React.Component { class Test extends React.Component {
state = { state = {
index: 0, index: 0,
...@@ -84,7 +82,14 @@ class Test extends React.Component { ...@@ -84,7 +82,14 @@ class Test extends React.Component {
<div> <div>
<div>This is a.</div> <div>This is a.</div>
<button onClick={this.handleClick}>click me({this.state.index})</button> <button onClick={this.handleClick}>click me({this.state.index})</button>
{
this.state.index % 2 &&
<Provider>
<KeepAlive key="111">
<Content /> <Content />
</KeepAlive>
</Provider>
}
</div> </div>
); );
} }
......
...@@ -73,7 +73,6 @@ export default class KeepAliveProvider extends React.PureComponent<IKeepAlivePro ...@@ -73,7 +73,6 @@ export default class KeepAliveProvider extends React.PureComponent<IKeepAlivePro
} }
public componentWillUnmount() { public componentWillUnmount() {
this.eventEmitter.clear();
this.existed = false; this.existed = false;
document.body.removeChild(this.storeElement); document.body.removeChild(this.storeElement);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment