Skip to content

Commit

Permalink
Merge branch 'master' into debug-component-thrashing
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianbote committed Aug 10, 2019
2 parents bf0d3ad + 97c0a2c commit 356ba58
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 27 deletions.
2 changes: 2 additions & 0 deletions compat/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ function memo(c, comparer) {
this.shouldComponentUpdate = shouldUpdate;
return h(c, assign({}, props));
}
Memoed.prototype.isReactComponent = true;
Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
Memoed._forwarded = true;
return Memoed;
Expand Down Expand Up @@ -389,6 +390,7 @@ function forwardRef(fn) {
delete props.ref;
return fn(props, ref);
}
Forwarded.prototype.isReactComponent = true;
Forwarded._forwarded = true;
Forwarded.displayName = 'ForwardRef(' + (fn.displayName || fn.name) + ')';
return Forwarded;
Expand Down
5 changes: 5 additions & 0 deletions compat/test/browser/forwardRef.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ describe('forwardRef', () => {
teardown(scratch);
});

it('should have isReactComponent flag', () => {
let App = forwardRef((_, ref) => <div ref={ref}>foo</div>);
expect(App.prototype.isReactComponent).to.equal(true);
});

it('should pass ref with createRef', () => {
let App = forwardRef((_, ref) => <div ref={ref}>foo</div>);
let ref = createRef();
Expand Down
5 changes: 5 additions & 0 deletions compat/test/browser/memo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ describe('memo()', () => {
teardown(scratch);
});

it('should have isReactComponent flag', () => {
let App = memo(() => <div>foo</div>);
expect(App.prototype.isReactComponent).to.equal(true);
});

it('should work with function components', () => {
let spy = sinon.spy();

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"dev:hooks": "microbundle watch --raw --format cjs --cwd hooks",
"dev:compat": "microbundle watch --raw --format cjs --cwd compat --globals 'preact/hooks=preactHooks'",
"test": "npm-run-all lint build --parallel test:mocha test:karma test:ts",
"test:flow": "flow check",
"test:ts": "tsc -p test/ts/ && mocha --require babel-register test/ts/**/*-test.js",
"test:mocha": "mocha --recursive --require babel-register test/shared test/node",
"test:karma": "cross-env COVERAGE=true karma start karma.conf.js --single-run",
Expand Down Expand Up @@ -125,7 +124,6 @@
"eslint": "5.15.1",
"eslint-config-developit": "^1.1.1",
"eslint-plugin-react": "7.12.4",
"flow-bin": "^0.79.1",
"karma": "^3.0.0",
"karma-babel-preprocessor": "^7.0.0",
"karma-chai-sinon": "^0.1.5",
Expand Down
1 change: 1 addition & 0 deletions src/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface VNode<P = {}> extends preact.VNode<P> {
*/
_lastDomChild: PreactElement | Text | null;
_component: Component | null;
constructor: undefined;
}

export interface Component<P = {}, S = {}> extends preact.Component<P, S> {
Expand Down
25 changes: 0 additions & 25 deletions src/preact.js.flow

This file was deleted.

0 comments on commit 356ba58

Please sign in to comment.