Commit Graph

8787 Commits

Author SHA1 Message Date
Andrew Clark 7c63d0178d Add missing space to key warning (#10179)
Found this when running the warnings script.
2017-07-13 16:14:45 -07:00
Andrew Clark 4dabdd2a30 Limit the number of nested synchronous updates (#10178)
* Limit the number of nested synchronous updates

In Stack, an infinite update loop would result in a stack overflow. This
gives the same behavior to Fiber.

Conceptually, I think this check belongs in findNextUnitOfWork, since
that is what we call right before starting a new stack. I've put it
in scheduleUpdate for now so I have access to the component that
triggered the nested update. But we could track that explicitly instead.

I've chosen 1000 as the limit rather arbitrarily. Most legit use cases
should really have a much smaller limit, but a smaller limit could break
existing code. For now I'm only concerned with preventing an infinite
loop. We could add a warning that fires at the smaller limit.

* Move check to findNextUnitOfWork

Including the name of the component in the message probably isn't
necessary. The JS stack will include either componentDidUpdate or
componentWillUpdate. And the component that's updating won't
necessarily be the component whose lifecycle triggered it.

So let's move the infinite loop check to findNextUnitWork as I
originally wanted to.
2017-07-13 15:56:02 -07:00
Jason Quense 999df3e777 Fix uncontrolled radios (#10156)
* Add fixture

* Fix Uncontrolled radio groups

* address feedback

* fix tests; prettier

* Update TestCase.js
2017-07-13 16:02:31 -04:00
Dan Abramov 2dcdc3c633 Simplify environment injections (#10175)
* Remove unnecessary injection guard

* Remove inject() indirection for global injections

It was necessary when they shared global state. But now these are flat bundles so we can inject as side effect.
This feels a bit less convoluted to me.

Ideally we can get rid of this somehow soon.
2017-07-13 20:44:52 +01:00
Dan Abramov 0070925a4f Don't use Stack-only helper in new SSR (#10174) 2017-07-13 19:55:48 +01:00
Dan Abramov 7dd7c1702b Remove dependency to event system on the server (#10173)
I do this by splitting ReactDOMInjection into generic and client-only injection.
2017-07-13 19:32:27 +01:00
Flarnie Marchan 309412d8b6 Improve error message thrown in Fiber with multiple copies of React (#10151)
* WIP Improve error message thrown in Fiber with multiple copies of React

**what is the change?:**
Adding an 'invariant' with detailed error message for the problem that
occurs when you load two copies of React with the Fiber reconciler.

WIP:
 - Is there any other likely cause for this error besides two copies of
   React?
 - How can we make the message more clear?

Still TODO:
 - Write a unit test
 - Write a documentation page and create the link to the page, similar
   to https://facebook.github.io/react/warnings/refs-must-have-owner.html

It would also be nice to have a page with instructions on how to fix
common cases of accidental double-loading of React, but we can open a
separate issue on that and let the community do it.

**why make this change?:**
This error comes up relatively often and we want to make things clear
when it happens in v16.0+

**test plan:**
WIP

**issue:**
Fixes #9962

* Add improved warning and docs for 'refs must have owner' in Fiber

**what is the change?:**
 - Added warning in the place where this error is thrown in Fiber, to
   get parity with older versions of React.
 - Updated docs to mention new error message as well as old one.

I started to write a new docs page for the new error, and realized the
content was the same as the old one. So then I just updated the existing
error page.

**why make this change?:**
We want to avoid confusion when this error is thrown from React v16.

**test plan:**
- manually inspected docs page
- manually tested in a CRA to trigger the error message

(Flarnie will insert screenshots)

**issue:**
Fixes #9962
Related to #8854

* Add test for the informative warning around multiple react copies

@gaearon debugged the test for this and now it works!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)

**what is the change?:**
We now test for the warning that the previous commits add in Fiber, and
also test for the old warning in the stack reconciler.

**why make this change?:**
This is an especially important warning, and we want to know that it
will fire correctly.

**test plan:**
`yarn test src/renderers/__tests__/multiple-copies-of-react-test.js`
`REACT_DOM_JEST_USE_FIBER=1 yarn test src/renderers/__tests__/multiple-copies-of-react-test.js`

* Fix up test for 'multiple copies of react'

**what is the change?:**
refactor test for 'multiple copies of React' to be simpler and remove
some copypasta

* run prettier

* Fix conditionals in 'multiple copies of react' test

**what is the change?:**
When moving the 'fiber' and 'non-fiber' conditions from two assertions
into one, we copy pasted the wrong message into the 'fiber' condition.

This wasn't caught because we were using an outdated name for the
'fiber' constant when running the tests locally with fiber enabled.

This fixes the copy-paste error and we now are actually running the
tests with fiber enabled locally.

* Run scripts/fiber/record-tests
2017-07-13 10:41:32 -07:00
Brian Vaughn 5495e495de Remove conditional __DEV__ wrapper from RN bundles (#10171)
This causes an error with the older version of JSC packaged for Android.
2017-07-13 09:26:45 -07:00
Flarnie Marchan 3b43f3190b Reword duplicate key warning (#10148)
* Reword duplicate key warning

**what is the change?:**
 - Removes the now-inaccurate description of behavior around duplicate
   keys
 - Adds link to 'key' docs page
 - Changes tone to be more casual and friendly

Alternative wording idea;
'Encountered two children with the same key, ${key}
Child keys must be unique; using duplicate keys is not supported and
will cause unexpected behavior in some versions of React.
See https://fb.me/react-warning-keys for more information on how to
fix this.'

**why make this change?:**
Mainly this change was needed because in React 16, duplicate keys will
not cause omission of items with duplicate keys. All items will be
rendered. It could happen that in future versions of React we will have
different behavior though.

**test plan:**
`yarn test`

**issue:**
Wishlist item on https://github.com/facebook/react/issues/8854

* Further improve wording of duplicate key error

**what is the change?:**
Another tweak to the wording of this error to make it more clear and
accurate.

**why make this change?:**
The previous tweak was too casual in tone and still not clear enough.

**test plan:**
`yarn test` and `REACT_DOM_JEST_USE_FIBER=1 yarn run test`

**issue:**
Wishlist item on https://github.com/facebook/react/issues/8854

* Run prettier

* Fix typo in error message for duplicate keys

**what is the change?:**
Fixed a typo in the updated message

* Fix two more typo spots
2017-07-12 15:49:41 -07:00
Garrett McCullough 50d905b083 change the argument passed to CallbackQueue.getPooled (#10101)
* change the argument passed to CallbackQueue.getPooled

* remove undefined from function call

* add test for ReactNativeReconcileTransaction

* update log of tests

* change test to one that operates on setState

* added new tests and fixed another instance of the bug

* run prettier

* update names of tests and minor clean up

* remove arg from CallbackQueue and update tests
2017-07-12 18:49:13 +01:00
Michiya 5d5589b295 Update conferences.md (#10160) 2017-07-12 12:31:45 -05:00
Brandon Dail d04618b28b Run all fixtures through Prettier (#10157)
* Include fixtures in prettier default pattern

* Run all fixtures through Prettier
2017-07-12 11:19:24 -05:00
Peter Ruibal cff012fc16 Add react-dom-unstable-native-dependencies (#10138)
* Add react-dom-unstable-native-dependencies

react-native-web and react-primitives currently access a few internals
for shimming DOM events into native ones.  Changes in react@16 packaging
hide these internals completely.  This change adds a submodule to react-dom,
unstable-native-dependencies that includes the necessary modules to
continue enabling that method of dom-native event injection.

* Update ResponderEventPlugin to use "public" interfaces for test

In order to get some sort of smoke testing on
react-dom-unstable-native-dependencies, update ResponderEventPlugin-test
to use the "public" interfaces provided by react-dom and the new
react-dom/unstable-native dependencies

Also adds the missing references in package.json as well as missing
files required for unittests to do imports correctrly

Also exports injectComponentTree() which is required for the unittests
to re-set the shared component state between runs.

* Tweak bundle comment

* Bundle content updates from exporting injectComponentTree

* Added FB_DEV, FB_PROD to bundle types

* Run yarn prettier for -unstable-native-dependencies updates
2017-07-12 02:27:26 +01:00
Dan Abramov 2e2f503cb8 Tweak deprecation messages to be less scary (#10145) 2017-07-11 14:05:27 +01:00
walrusfruitcake b79619e52a move augmentClass definition above SyntheticEvent Proxy replacement (#10011) 2017-07-11 11:37:11 +01:00
Brandon Dail ab4ddf6493 Add columns to isUnitlessNumber list (#10115) 2017-07-11 11:28:57 +01:00
Eli White 8ca40630e6 Adding missing assertion to ReactDOMComponent-test (#10131) 2017-07-10 18:51:44 -06:00
Dheeraj Kumar 5ac6209599 Fix shallow renderer callbacks (#10106)
* Add failing test to show that shallow test renderer doesn't call setState's callback arg
* Record tests
* Fix shallow renderer's setState/replaceState/forceUpdate to execute any callbacks passed. (#10089)
* Ensure shallow renderer callbacks are called with the correct  binding.
2017-07-10 14:41:50 -07:00
Eli White 5bc25cb186 Fixing typo in ReactDOMComponent test name (#10132) 2017-07-09 19:34:39 -04:00
Martin V 242929bac1 Add Node v8.x support to devEngines in package.json (#10129) 2017-07-09 20:24:33 +01:00
Andrew Clark ce7c01429c Don't increase priority when cloning current children (#10123)
This fixes a snapshot test regression introduced by #10008. I had
noticed this change and believe the new behavior was correct, but upon
further investigation I was wrong. This reverts the snapshot test and
fixes it accordingly.
2017-07-07 15:34:27 -07:00
Nick Kasten 8f4d30737d Updated Immutable Data Stuctures Docs (#9845)
* updated immutable data structures section

* improved immutable clarifications

* changes to example immutable code
2017-07-05 19:08:43 -05:00
Ilya Gelman b22387d4fe Add ReactNext 2017 to conference list (#10114) 2017-07-05 18:44:04 -05:00
Andrew Rota a39858f399 Add React Boston 2017 to upcoming conferences (#10099) 2017-07-03 21:07:09 -04:00
Guilherme Ruiz 83f56370e6 Fix the data-height of Step 5 CodePen embed (#10083) 2017-07-03 21:05:35 -04:00
Kiho · Cham 03db57aa71 doc: fix the order of lint and prettier (#10095) 2017-07-02 17:39:09 +01:00
Kiho · Cham 4880eb0fbc doc: switch the order of lint and prettier (#10094)
Ref #9876

Thanks to @wdhorton bring it up.
2017-07-02 13:24:45 +01:00
Andrew Clark f9af9aacd3 Down-prioritize children of hidden host components
To make sure we don't reset the priority of a down-prioritized fiber,
we compare the priority we're currently rendering at to the fiber's
work priority. If the work priority is lower, then we know not to reset
the work priority.
2017-06-30 18:39:04 -07:00
Andrew Clark de08c2af15 Ignore incremental tests that assert on work reuse
it -> xit

The diff looks messier than it actually is because of Prettier.
2017-06-30 18:39:04 -07:00
Andrew Clark 5a32e89b3d Failed error boundaries are a special case of resuming work
When an error in thrown in the begin phase, we begin work on the
error boundary a second time to unmount the children. This is a special
case of "resuming" work that we need to account for. The children are
set to the current children so that we can delete them.
2017-06-30 18:39:04 -07:00
Andrew Clark ccbb92f9ef Enable the fuzz tester
Now that we've removed the buggy implementation of resuming work, the
fuzz tester passes consistently.
2017-06-30 18:39:04 -07:00
Andrew Clark 264a921054 Clear pending props when cloning from current
When we create a new work-in-progress, the existing pending props are
no longer valid.
2017-06-30 18:39:04 -07:00
Andrew Clark a0af1e1317 Remove ability to resume work
The current implementation of resuming work is buggy. The underlying
model is also flawed. Rather than attempt to fix a flawed model, we'll
scrap the feature entirely and add it back later.
2017-06-30 18:39:04 -07:00
Andrew Clark 9749a6ea6a Update fuzz tester to not use animation priority
Neglected to fix this earlier because these tests were ignored.
2017-06-30 18:39:04 -07:00
Sebastian Markbåge e6f1d29f07 Warn for inline style mismatches (#10084)
I use the technique of generating a style string and comparing that against the
attribute.
2017-06-30 18:24:04 -07:00
Almero Steyn 79868a978d docs(a11y): Small fixes (#10079) 2017-06-30 07:39:46 -04:00
Sebastian Markbåge 8d61138186 Warn When The HTML Mismatches in DEV (#10026)
* Warn for text content

* Warn for different attributes/properties values

Warns if there are unknown extra attributes in the hydrated node.

It also tries to compare the existing property or attribute against the
expected value. It does this by reading the property and comparing it to
the prop. Except it's not that simple because multiple prop values can
yield the same output. For this we pass an extra expected value that is
a hint as to which one was used. This is a bit weird but I'm not sure the
alternatives were much better.

* Warn when there is an insertion or deletion during hydration

This warns if there is ever an insertion or deletion due to hydration
failing to find a match.

Currently we can't warn for insertions required into the root because
that's how we do all non-hydrating renders atm. Left a todo.

This strategy is a bit unfortunate that it leads to so much plumbing code.
And we have to add three extra methods to the HostConfig that are only used
in DEV and not for anything else. I don't really have a better idea.

* Don't try to delete children of a textarea

Textareas are special cases. The initial mount inserts children
as the default value, but we should leave that untouched. This is the same
as the special case where we set text content of children so I'll use that
mechanism.

* Change expected format for text differences

In Stack this is presented as HTML which needs to have normalized escaping
rules. In Fiber it is currently not presented as HTML but a raw string
so we don't escape it.

* Unmount component in between tests

In Fiber, the second warning isn't issued because it's considered an update
not a new initial render and we don't fire the warning for those.

* Change expectation of white space text behavior in Fiber

In Fiber we don't expect empty strings to be different from rendering null.
In fact, in a follow up I plan on formalizing this by never creating text
Fibers for empty strings.

* Warn for different dangerouslySetInnerHTML

We can't just compare the raw innerHTML value because it will have been
normalized. Instead, we'll create another element, set its innerHTML and
read it back.

Since there can be custom elements registered with this document, we want
to avoid any side-effects they might cause. So I do this in a fresh new
document.

I'm not sure how this would affect controlled components and other stuff
that could have changed after runtime. I think for those cases maybe we
just need a general way of opting out of the diff.
2017-06-29 19:47:44 -07:00
Nathan Hunzaker 9d13557244 Add test to ensure extra zeros are covered by tests (#10033)
* Add test to ensure extra zeros are covered by tests

* Add DOM test fixture for trailing zeros

* Drop quotes to improve clarity
2017-06-29 12:44:05 -05:00
Henry Harris dccc3850dc Tiny changes to tutorial (#10048)
* Initial commit

* PR feedback
2017-06-29 16:00:04 +01:00
Ben Alpert 21df484f25 Don't build ReactDOMNodeStream for FB (#10065)
require('stream') doesn't work for us right now.
2017-06-28 16:13:58 -07:00
Toru Kobayashi 85f3498fda Types Fiber as an exact object type (#10063) 2017-06-28 13:01:46 -05:00
Ben Alpert 864ae8fa98 Support comment node as a mount point (#9835)
This means you don't need an extra wrapper div for each component root you need. Rendered stuff is inserted before the comment you pass in.
2017-06-27 17:22:07 -07:00
Sebastian Markbåge 52a2365f19 Fix mount and unmount warnings in Fiber (#10056)
* Warn if unmounting a non-container

* Warn if the 2nd+ child is a "root" element but not first

This triggers our non-reuse mode. This is covered by ReactMount already but
the test doesn't pass yet without also landing #10026.
2017-06-27 17:15:53 -07:00
Sasha Aickin f8a3a3989a Removed ReactMarkupChecksum from renderToString (#10053)
* Removed ReactMarkupChecksum from renderToString

* Oops. I messed up the merge in the previous commit.
2017-06-27 14:20:45 -07:00
Sebastian Markbåge e955008b9b Remove most comments from HTML generation output (#10029)
Simplifies markup generation by only inserting a simple comments between
consecutive text nodes.

I also skip past comments and other nodes while hydrating. This leaves them
in place instead of being removed by the hydration mechanism. This is more
efficient but will also be needed by hydration validator.

There's a special case for empty strings. We probably shouldn't have nodes
for those at all. For now I special case it by assuming there won't be one
so if we need one, we'll insert an empty text node.

I also dropped the ID from the react ID.
2017-06-27 10:43:27 -07:00
Sebastian Markbåge 3c5b515286 Update yarn.lock (#10046) 2017-06-27 10:41:54 -07:00
Jack Ford 7831440dc9 Fix Typo in ReactFiberTreeReflection (#10055) 2017-06-27 17:53:16 +01:00
Jack Ford 15d3f2852f Fix Typo in ReactDOMFiberEntry (#10054) 2017-06-27 17:53:10 +01:00
Sebastian Markbåge 90b7facd52 Don't use the render callback with promises (#10050)
This covers up errors that are thrown in Fiber, because callback gets
fired *and* an error is thrown. Created a follow up #10049 to reevaluate
these semantics.

# Conflicts:
#	scripts/fiber/tests-passing-except-dev.txt
#	scripts/fiber/tests-passing.txt
2017-06-27 08:24:31 -07:00
Brian Vaughn cb32253d2f ReactNativeFiberErrorDialog mutates error message (#10045)
This ensures that custom properties that are required by Facebook's error tooling (eg 'framesToPop') don't get dropped.

I also improved the handling/messaging of thrown strings.
2017-06-26 12:34:29 -07:00