Commit Graph

120 Commits

Author SHA1 Message Date
Ben Alpert efaa26eb50 Upgrade jest APIs to match www (#8536)
D4298654, D4298713
2016-12-21 19:07:40 -08:00
dfrownfelter b106ca0c8e Delete fiveArgumentPooler (#8597) 2016-12-19 22:53:04 -06:00
Dan Abramov e36b38c1ca [Fiber] Fix some of the warnings (#8570)
* Implement component stack for some warnings in Fiber

* Keep Fiber debug source up to date

When an element changes, we should copy the source and owner again.
Otherwise they can get stale since we're not reading them from the element.

* Remove outdated TODOs from tests

* Explicitly specify Fiber types to include in the stack

Fixes an accidental omission when both source and owner are null but displayName exists.

* Fix mised Stack+Fiber test to not expect extra warnings

When we're in Fiber mode we don't actually expect that warning being printed.

* Warn on passing different props to super()

* Implement duplicate key warnings

We keep known keys in a set in development. There is an annoying special case where we know we'll check it again because we break out of the loop early.

One test in the tree hook regresses to the failing state because it checks that the tree hook works without a Set available, but we started using Set in this code. It is not essential and we can clean this up later when we decide how to deal with polyfills.

* Move ReactTypeOfWork to src/shared

It needs to be available both to Fiber and Isomorphic because the tree hook lives in Isomorphic but pretty-prints Fiber stack.

* Add dev-only ReactDebugCurrentFiber for warnings

The goal is to use ReactCurrentOwner less and rely on ReactDebugCurrentFiber for warning owner name and stack.

* Make Stack invariant messages more consistent

Fiber used a helper so two tests had the same phrasing.
Stack also used a helper for most invariants but hardcoded a different phrase in one place.
I changed that invariant message to use a helper which made it consistent with what it prints in Fiber.

* Make CSSPropertyOperations use getCurrentFiberOwnerName()

This gets mount-time CSS warnings to be printed.

However update-time warnings are currently ignored because current fiber is not yet available during the commit phase.

We also regress on HostOperation hook tests but this doesn't matter because it's only used by ReactPerf and it doesn't work with Fiber yet anyway. We'll have to think more about it later.

* Set ReactDebugCurrentFiber during the commit phase

This makes it available during updates, fixing the last failing test in CSSPropertyOperations.

* Add DOM warnings by calling hooks directly

It is not clear if the old hook system is worth it in its generic incarnation. For now I am just hooking it up to the DOMFiber renderer directly.

* Add client-side counterparts for some warning tests

This helps us track which warnings are really failing in Fiber, and which ones depend on SSR.
2016-12-15 08:36:58 -08:00
Dan Abramov c74034589e [Fiber] Support iterables (#8446)
* Add iterable cases to MultiChildReconcile test

Stack currently supports rendering iterables, but Fiber does not.

Previously we didn't have any public API tests for iterables. We have tests for traverseAllChildren() which is shared between React.Children and Stack. However Fiber doesn't currently use it, and likely won't. So this commit is a first step towards actually testing iterable support via public API. The next step will be to port traverseAllChildren() tests to test React.Children API instead.

* Implement iterable reconciliation in Fiber

This uses the same exact algorithm as array reconciliation but uses iterator to step through.

This gets reconcile tests to pass again but introduces a regression in ReactMultiChildText case which uses Maps as children. It passed before because Maps were ignored, but now it's failing because this actually runs the Map code path in Fiber. We can throw early in this case when we want to follow up on this.

* Rewrite traverseAllChildren() tests against React.Children API

This function was used in React.Children and Stack.

The corresponding reconciliation functionality is being tested by ReactMultiChild tests.

So we can move these tests to ReactChildren and test its public API.
2016-11-28 23:44:56 +00:00
Tom Occhino 32f5b034ed Upgrade ESLint and dependencies, fix new lint errors, switch Travis to Yarn (#8309)
* Update ESLint to 3.10.2

Also pull in fbjs for extending properly, per @zpao. This also disables consistent-return, which has about 80 failing cases in React currently. If we'd like to turn this back on, we should do it separately and fix all the call sites properly (rather than just adding 'return undefined;' everywhere, which adds no value.

Fixes to all existing lint errors plus an update for yarn.lock to follow.

* Update yarn.lock after the eslint update.

* Fix all new eslint failures

Unfortunately I had to add three eslint-disable-next-line instances. All have explanations inline.

* Switch Travis to use yarn instead of npm
2016-11-17 22:16:44 +00:00
Ben Alpert 4aa9cfb6ba Change warnings to use expectDev 2016-11-14 13:22:41 +00:00
Dan Abramov c17bf38035 Get a few more Fiber tests passing (#8149)
* Get a few more Fiber tests passing

* Fix Flow and wrap in __DEV__
2016-10-30 00:43:34 +01:00
Josh Perez 6eebed0535 Shares debugID information across modules (#8097)
Prior to this, React was using a nextDebugID variable that was locally
scoped to both `instantiateReactComponent` and `ReactShallowRenderer`.
This caused problems when the debugIDs would collide, the `itemMap` in
`ReactComponentTreeHook` would be overwritten and tests would fail
with the message "Expected onBeforeMountComponent() parent and
onSetChildren() to be consistent".

This change shares the debugID with both modules thus preventing any
collisions in the future.
2016-10-27 10:31:10 +01:00
Dan Abramov 14156e56b9 Strip PropTypes checkers in production build (#8066)
* Strip PropTypes in production build

* Revert "Warn if PropType function is called manually (#7132)"

This reverts commit e75e8dcbeb.
2016-10-24 18:43:31 +01:00
Christopher Chedeau 334b8bdf16 I wrote it live! (#7663) 2016-09-06 15:18:42 -07:00
Ben Alpert 0722b15752 Small flow fixes 2016-09-01 15:52:29 -07:00
Christopher Chedeau 19b8eadb24 Type PooledClass (#7578)
This one was really interesting to type as it's doing a lot of unusual JavaScript. Fortunately flow is now pretty kick ass and I've been able to mostly type it. The only missing piece is that it won't check the constructor arguments.

If you are a fb employee, you can follow the discussion here: https://www.facebook.com/groups/flowtype/permalink/1132359430146004/
2016-08-28 10:43:13 -07:00
Christopher Chedeau 84084153ed Remove keyMirror in ReactPropTypeLocations (#7592)
This one involves a bit more work as I added "phantom" flow types to a bunch of places where the type is a ReactPropTypeLocations even though those files are not `@flow` yet.

A good side effect is that `ReactPropTypeLocationNames` keys are now correctly typed, this means that they cannot go out of sync without breaking flow :)
2016-08-28 10:30:15 -07:00
Christopher Chedeau 563f3bbab4 Type ReactPropTypesSecret (#7501) 2016-08-25 15:26:38 -07:00
Christopher Chedeau a72a156f58 Type ReactElementSymbol (#7564) 2016-08-25 15:23:29 -07:00
Christopher Chedeau 18003578b1 Type canDefineProperty (#7500) 2016-08-25 10:46:49 -07:00
Christopher Chedeau ad3c65186e Type ReactPropTypeLocations (#7502) 2016-08-25 10:46:26 -07:00
Christopher Chedeau 7f64baad78 Type ReactPropTypeLocationNames (#7503) 2016-08-25 10:46:15 -07:00
Sebastian Markbåge 1c5a639c37 Require the isomorphic React instead of internals from renderers (#7473)
This is needed for flat builds. It also lets us get rid of a bunch
of special cases in the build scripts.

It also allow us to just copy the source files into React Native
instead of having to build first to resolve the special cases.
2016-08-11 18:56:55 -07:00
Dan Abramov 178cb7d339 Prevent performance regression in DEV due to warning arguments (#7461)
* Prevent internal performance regression

This only affects Facebook website, not open source version of React.

On the Facebook website, we don't have a transform for warnings and invariants.
Therefore, expensive arguments will be calculated even if the warning doesn't fire.
This fixes a few cases where that calculation might be more expensive than usually.

In my testing, this brings down average row click time in Power Editor from ~300ms to ~220ms in __DEV__ (vs ~40ms in prod).

* Put warning() that shows up in profile behind condition
2016-08-10 19:52:46 +01:00
Nathan Hunzaker 8aed0cd67e Add some semicolons for linting. (#7390) 2016-08-01 21:17:58 +01:00
Keyan Zhang f2fc182250 renamed modules (devtool -> hook) 2016-07-29 16:12:23 -07:00
Keyan Zhang 4d8a5bcd5c codemodded tests from createClass to ES2015 classes
- reverted more files under classic
2016-07-23 15:16:12 -07:00
Dan Abramov 15ae5857f6 Eagerly evaluate inline requires in Jest (#7245)
* Eagerly evaluate inline requires in Jest

I inlined some requires in #7188 to fix the build size regression.
However this caused an issue with Jest due to it resetting module registry between tests.

This is a temporary fix to #7240.
It should be reverted as part of #7178.

* Make the hack work in all environments
2016-07-16 20:51:25 +01:00
Keyan Zhang 5103e1d6a1 warn for using maps as children with owner info (#7260) 2016-07-13 08:29:42 -07:00
Dan Abramov 8fe6b5fb46 Inline dev-only requires (#7188)
* Inline dev-only requires

This reduces the production bundled build size.

* Use new references after resetting module registry in tests

This fixes the tests which were broken due to inlining some requires.
2016-07-05 18:20:12 +01:00
Christopher Chedeau 07cfba17a9 [flow] fix flattenChildren type (#7110)
Summary:
Make the debug attribute optional

Test Plan:
npm run flow

Reviewers: @keyanzhang @chicoxyzzy
2016-07-05 09:18:49 -07:00
Sebastian Markbåge 4bc1048e0d Unshare not actually shared files (#7167)
This moves some files out of shared that are not actually shared
with isomorphic. They're specific to the renderers.
2016-07-01 19:16:52 -07:00
Esteban 752e1595fc Remove comment about PooledClass destructors being optional (#6560)
They are no longer optional since #4720
2016-06-26 21:52:12 +01:00
Sergey Rubanov 3b5c756c7a [flow] add some typings to utils (#7104)
* add some typings to utils

* add typing of flattenChildren

* more accurate typings for flattenChildren
2016-06-23 18:16:37 +02:00
Christopher Chedeau 9342c2f02f [flow] type deprecated (#7076)
Summary:

Test Plan:
npm run flow

Reviewers: @zpao @spicyj @gabelevi
2016-06-23 17:46:24 +02:00
Christopher Chedeau 489caeb2d7 [flow] type adler32 (#7080)
This one is trivial

Test Plan:
npm run flow

Reviewers: @zpao @spicyj
2016-06-20 15:35:59 +02:00
Christopher Chedeau 12a6ad1ef5 [flow] type KeyEscapeUtils (#7079)
Summary:

The only call site ensures that the value is not null: https://github.com/facebook/react/blob/dc6fc8cc0726458a14f0544a30514af208d0098b/src/shared/utils/traverseAllChildren.js#L44

key is stringified inside of createElement, so we are guaranteed to receive a string right now: https://github.com/facebook/react/blob/dc6fc8cc0726458a14f0544a30514af208d0098b/src/isomorphic/classic/element/ReactElement.js#L142

Test Plan:
npm run flow

Reviewers: @zpao @spicyj
2016-06-19 21:58:21 +02:00
Christopher Chedeau 1c71970431 [flow] annotate accumulate and accumulateInto
Summary:
Trying to start adding flow types to files in React. I needed to add a script to package.json in order to run flow, flow-bin is already a dependency.

I had to rewrite the implementation a bit. Flow doesn't recognize

```
var currentIsArray = Array.isArray(current);
if (currentIsArray) {
  // not refined
}
```

but the following does work

```
if (Array.isArray(current)) {
  // refined
}
```

Test Plan:
npm run-script flow
npm run-script test accumulate

Reviewers: @zpao @spicyj
2016-06-16 17:33:32 +02:00
Keyan Zhang 1abce1630c Add reactProdInvariant and corresponding babel rewrite pass (#6948) 2016-06-07 17:11:04 -07:00
Dmitrii Abramov 517ed859b4 Upgrade to Jasmine 2 2016-05-25 21:48:32 +01:00
Paul O’Shannessy d8a0b9a662 Upgrade to jest-cli@0.9 and use Jasmine2 2016-05-25 21:48:32 +01:00
Keyan Zhang 47e49ae8b7 Add component stack info to key validation warnings (#6799)
* Add component stack info to key validation warnings

* Add `ReactComponentTreeDevtool.getStackAddendumByID`
2016-05-20 14:19:31 -07:00
Ben Alpert ba9b985406 Rename host-y things to be "host" not "native" (#6754)
For clarity.

I left "native event" as-is because there's a lot of it, it's not particularly ambiguous, and SimulateNative/nativeTouchData are public API in ReactTestUtils.
2016-05-11 23:22:59 -07:00
Ben Alpert 98cb2f8507 Revert "Don't wrap drag events in IE/Edge in dev builds" (#6741) 2016-05-10 10:58:35 -07:00
cpojer 8e34514096 Update to Jest 12. Codemod to new Jest APIs. 2016-04-28 14:54:57 +09:00
Dan Abramov 2723323006 Remove OrderedMap and ReactPropTransferer
These are not exposed publicly and have been deprecated.
2016-04-27 17:44:02 +01:00
hkal dc6fc8cc07 Helper for escaping and unescpaing component keys (#6500)
- Abstract escaping
- Provide human readible same key warnings
2016-04-15 20:55:37 -07:00
Jim 2e8f28c29f Merge pull request #6364 from p-jackson/issue-5700
Don't wrap drag events in IE/Edge in dev builds
2016-04-07 14:11:12 -07:00
Paul O’Shannessy 1573baaee8 Use Object.assign directly and inject object-assign at compile 2016-04-04 09:53:25 -07:00
Philip Jackson 4687a03f54 Don't wrap drag events in IE/Edge in dev builds
Dev builds wrap synthetic events inside other events for a better debug
experience. However IE/Edge won't allow access to the
DataTransfer.dropEffect property if it's wrapped in this way.
The first time a drag event is fired, test if we're in an environment
that behaves this way and disable React's improved development
experience if we are.
2016-03-28 00:29:46 +13:00
Michael McDermott 18af9bc91e Fixed some linting warnings and some mis-spacing in SyntheticEvent warnings. 2016-03-02 18:40:23 -05:00
Rick Beerendonk bef45b0b1a Year-agnostic copyright message, like React Native uses, to prevent the need for yearly changes. 2015-12-29 20:20:32 +01:00
Jim 3afced6a75 Error boundaries. 2015-12-16 12:15:26 -08:00
Ben Alpert 46f5251c66 Remove @typechecks
These don't really do anything.

```
codemod.py -d src --extensions js -m '\s* \* @typechecks.*?\n' '\n'
```

with "yes to all".
2015-12-10 11:26:45 -08:00