Commit Graph

14262 Commits

Author SHA1 Message Date
Brian Vaughn f2489f7ce7 Add .circleci/config.yml 2021-06-29 13:25:40 -04:00
Andrew Clark cae635054e act: Resolve to return value of scope function (#21759)
When migrating some internal tests I found it annoying that I couldn't
return anything from the `act` scope. You would have to declare the
variable on the outside then assign to it. But this doesn't play well
with type systems — when you use the variable, you have to check
the type.

Before:

```js
let renderer;
act(() => {
  renderer = ReactTestRenderer.create(<App />);
})

// Type system can't tell that renderer is never undefined
renderer?.root.findByType(Component);
```

After:

```js
const renderer = await act(() => {
  return ReactTestRenderer.create(<App />);
})
renderer.root.findByType(Component);
```
2021-06-26 11:51:23 -07:00
Andrew Clark e2453e2007 act: Add test for bypassing queueMicrotask (#21743)
Test for fix added in #21740
2021-06-25 12:39:46 -07:00
Brian Vaughn 73ffce1b6f DevTools: Update tests to fix warnings/errors (#21748)
Some new ones had slipped in (e.g. deprecated ReactDOM.render message from 18)
2021-06-24 22:42:44 -04:00
Dan Abramov 534c9c52ec Move error logging to update callback (#21737)
* Move error logging to update callback

This prevents double logging for gDSFE boundaries with createRoot.

* Add an explanation for the rest of duplicates
2021-06-24 20:57:10 +01:00
Dan Abramov 51b0becf3e Always keep disabled logs in the second pass (#21739)
* Add tests for disabled logs

* Always keep disabled logs in the second pass

* Jest nit

* Always use the second result
2021-06-24 19:50:07 +01:00
Brian Vaughn 386e8f2ea7 DevTools: Fix Settings dialog scroll/size bug in Firefox (#21747) 2021-06-24 11:19:57 -04:00
Dan Abramov 7fec38041f Log and show error overlay for commit phase errors (#21723)
* Enable skipped tests from #21723

* Report uncaught errors in DEV

* Clear caught error

This is not necessary (as proven by tests) because next invokeGuardedCallback clears it anyway. But I'll keep it for consistency with other calls.
2021-06-24 15:48:28 +01:00
Andrew Clark 27c9c95e23 act: Bypass microtask for "default sync" updates (#21740)
When wrapping an update in act, instead of scheduling a microtask,
we can add the task to our internal queue.

The benefit is that the user doesn't have to await the act call. We can
flush the work synchronously. This doesn't account for microtasks that
are scheduled in userspace, of course, but it at least covers
React's usage.
2021-06-23 17:32:44 -07:00
Brian Vaughn 8426bb6956 Pass Jest useStderr flag when debugging (#21741)
This prevents it from buffering adn suppressing all console logs until a test has completed running (When debugging in Chrome).
2021-06-23 16:58:46 -04:00
Dan Abramov e577bfb1ce Add tests for invokeGuardedCallback (#21734)
* Add tests for invokeGuardedCallback

* Add skipped failing tests

* Check next render works

* Mirror tests for createRoot

* Move comments around
2021-06-23 21:47:47 +01:00
Brian Vaughn 355591add4 Next/experimental release versions include commit date (#21700)
Change format of @next and @experimental release versions from <number>-<sha> to <number>-<sha>-<date> to make them more human readable. This format still preserves the ability for us to easily map a version number to the changes it contains, while also being able to more easily know at a glance how recent a release is.
2021-06-23 13:50:09 -04:00
Andrew Clark d7dce572c7 Remove internal act builds from public modules (#21721)
* Move internal version of act to shared module

No reason to have three different copies of this anymore.

I've left the the renderer-specific `act` entry points because legacy
mode tests need to also be wrapped in `batchedUpdates`. Next, I'll update
the tests to use `batchedUpdates` manually when needed.

* Migrates tests to use internal module directly

Instead of the `unstable_concurrentAct` exports. Now we can drop those
from the public builds.

I put it in the jest-react package since that's where we put our other
testing utilities (like `toFlushAndYield`). Not so much so it can be
consumed publicly (nobody uses that package except us), but so it works
with our build tests.

* Remove unused internal fields

These were used by the old act implementation. No longer needed.
2021-06-22 14:29:35 -07:00
Andrew Clark 06f7b4f43a act should work without mock Scheduler (#21714)
Currently, in a React 18 root, `act` only works if you mock the
Scheduler package. This was because we didn't want to add additional
checks at runtime.

But now that the `act` testing API is dev-only, we can simplify its
implementation.

Now when an update is wrapped with `act`, React will bypass Scheduler
entirely and push its tasks onto a special internal queue. Then, when
the outermost `act` scope exists, we'll flush that queue.

I also removed the "wrong act" warning, because the plan is to move
`act` to an isomorphic entry point, simlar to `startTransition`. That's
not directly related to this PR, but I didn't want to bother
re-implementing that warning only to immediately remove it.

I'll add the isomorphic API in a follow up.

Note that the internal version of `act` that we use in our own tests
still depends on mocking the Scheduler package, because it needs to work
in production. I'm planning to move that implementation to a shared
(internal) module, too.
2021-06-22 14:25:07 -07:00
Andrew Clark 422e0bb360 Delete test-utils implementation of act (#21703)
* Delete test-utils implementation of `act`

Since it's dev-only now, we can use the one provided by the reconciler.

* Move act related stuff out of EventInternals
2021-06-22 14:21:22 -07:00
Sebastian Markbåge 568dc3532e Remove unstable_createRoot from internal builds (#21698)
These callsites were already removed as far as I can tell.
2021-06-17 11:29:30 -07:00
Dan Abramov 43f4cc1608 Fix failing test (#21697) 2021-06-17 13:56:18 +01:00
Brian Vaughn d0f348dc1b Fix for failed Suspense layout semantics (#21694)
Co-authored-by: Dan Abramov <dan.abramov@me.com>
2021-06-16 19:44:44 -04:00
Andrew Clark bd0a963445 Throw when act is used in production (#21686)
Upgrades the deprecation warning to a runtime error.

I did it this way instead of removing the export so the type is the same
in both builds. It will get dead code eliminated regardless.
2021-06-16 16:29:51 -04:00
Dan Abramov a0d2d1e1e1 Fix fixture lockfile manually 2021-06-16 00:04:01 +01:00
Dan Abramov 6cbf2a8b3b Add missing package lock 2021-06-15 23:52:15 +01:00
Dan Abramov c0a77029c4 Remove unused variable 2021-06-15 23:49:41 +01:00
Dan Abramov f283d7524a Use npm lockfile for fixture 2021-06-15 23:49:04 +01:00
Dan Abramov 03c5314b44 [SSR2 Fixture] Update APIs (#21688) 2021-06-15 23:20:51 +01:00
Sebastian Markbåge 7ec4c55971 createRoot(..., {hydrate:true}) -> hydrateRoot(...) (#21687)
This adds a new top level API for hydrating a root. It takes the initial
children as part of its constructor. These are unlike other render calls
in that they have to represent what the server sent and they can't be
batched with other updates.

I also changed the options to move the hydrationOptions to the top level
since now these options are all hydration options.

I kept the createRoot one just temporarily to make it easier to codemod
internally but I'm doing a follow up to delete.

As part of this I un-dried a couple of paths. ReactDOMLegacy was intended
to be built on top of the new API but it didn't actually use those root
APIs because there are special paths. It also doesn't actually use most of
the commmon paths since all the options are ignored. It also made it hard
to add only warnings for legacy only or new only code paths.

I also forked the create/hydrate paths because they're subtly different
since now the options are different. The containers are also different
because I now error for comment nodes during hydration which just doesn't
work at all but eventually we'll error for all createRoot calls.

After some iteration it might make sense to break out some common paths but
for now it's easier to iterate on the duplicates.
2021-06-15 13:37:53 -07:00
Sebastian Markbåge 9212d994ba Merge /unstable-fizz entry point into /server (#21684) 2021-06-14 18:37:44 -07:00
Sebastian Markbåge 9343f87203 Use the server src files as entry points for the builds/tests (#21683)
* Use the server src files as entry points for the builds/tests

We need one top level entry point to target two builds so we can't have
the top level one be the entry point for the builds.

* Same thing but with the modern entry point
2021-06-14 16:23:19 -07:00
Sebastian Markbåge e601854f07 Clean up partial renderer entry points (#21682)
* Clean up partial renderer entry points

I made a mistake by leaving server.browser.stable in which is the partial
renderer for the browser build of stable. That should use the legacy fizz
one.

Since the only usage of the partial renderer now is at FB and we don't use
it with Node, I removed the Node build of partial renderer too.

* Remove GC test

No code is running this path anymore. Ideally this should be ported to
a Fizz form.
2021-06-14 15:44:46 -07:00
Sebastian Markbåge 502f8a2a07 [Fizz/Flight] Don't use default args (#21681)
* Don't use default args

* Hoist out creation for better inlining

The closures prevent inlining otherwise.
2021-06-14 15:28:20 -07:00
Sebastian Markbåge bd45ad05dc Add a DOCTYPE to the stream if the <html> tag is rendered (#21680)
This makes it a lot easier to render the whole document using React without
needing to patch into the stream.

We expect that currently people will still have to patch into the stream
to do advanced things but eventually the goal is that you shouldn't
need to.
2021-06-14 13:57:17 -07:00
Dan Abramov a8f5e77b92 Remove invokeGuardedCallback from commit phase (#21666)
* Remove invokeGuardedCallback from commit phase

* Sync fork
2021-06-14 21:45:53 +01:00
Sebastian Markbåge dbe3363ccd [Fizz] Implement Legacy renderToString and renderToNodeStream on top of Fizz (#21276)
* Wire up DOM legacy build

* Hack to filter extra comments for testing purposes

* Use string concat in renderToString

I think this might be faster. We could probably use a combination of this
technique in the stream too to lower the overhead.

* Error if we can't complete the root synchronously

Maybe this should always error but in the async forms we can just delay
the stream until it resolves so it does have some useful semantics.

In the synchronous form it's never useful though. I'm mostly adding the
error because we're testing this behavior for renderToString specifically.

* Gate memory leak tests of internals

These tests don't translate as is to the new implementation and have been
ported to the Fizz tests separately.

* Enable Fizz legacy mode in stable

* Add wrapper around the ServerFormatConfig for legacy mode

This ensures that we can inject custom overrides without negatively
affecting the new implementation.

This adds another field for static mark up for example.

* Wrap pushTextInstance to avoid emitting comments for text in static markup

* Don't emit static mark up for completed suspense boundaries

Completed and client rendered boundaries are only marked for the client
to take over.

Pending boundaries are still supported in case you stream non-hydratable
mark up.

* Wire up generateStaticMarkup to static API entry points

* Mark as renderer for stable

This shouldn't affect the FB one ideally but it's done with the same build
so let's hope this works.
2021-06-14 12:54:30 -07:00
Dan Abramov 101ea9f55c Set deletedTreeCleanUpLevel to 3 (#21679) 2021-06-14 20:10:24 +01:00
Dan Abramov 1a106bdc2a Wrap eventhandle-specific logic in a flag (#21657) 2021-06-11 21:08:32 +01:00
Brian Vaughn 3ba2b67f21 Update react_18.md 2021-06-11 14:27:09 -04:00
Brian Vaughn 905f6f48d4 Update react_18.md 2021-06-11 14:25:47 -04:00
Brian Vaughn ca4e650ec1 Update react_18.md 2021-06-11 14:24:09 -04:00
Brian Vaughn 42a89d5c61 Update react_18.md 2021-06-11 14:22:57 -04:00
Brian Vaughn 1e3ceadcc0 Added React 18 issue template 2021-06-11 14:19:37 -04:00
Brian Vaughn 01be61c12f DevTools can inspect Proxies that return broken iterator functions (#21660) 2021-06-11 10:15:48 -04:00
Timothy Yung cb30388d10 Export React Native AttributeType Types (#21661) 2021-06-11 00:45:49 -07:00
Sebastian Markbåge c1536795ca Revert "Make enableSuspenseLayoutEffectSemantics static for www (#21617)" (#21656)
This reverts commit 39f0074892.
2021-06-10 10:12:31 -07:00
Samuel Susla c96b78e0e7 Add concurrentRoot property to ReactNativeTypes (#21648)
* Add concurrentRoot property to ReactNativeTypes

* Add concurrentRoot to ReactNativeType

* Use ReactFabricType instead of ReactNativeType
2021-06-10 08:59:22 -04:00
Andrew Clark aecb3b6d11 Deprecate ReactDOM.render and ReactDOM.hydrate (#21652)
* Use existing test warning filter for server tests

We have a warning filter for our internal tests to ignore warnings
that are too noisy or that we haven't removed from our test suite yet:
shouldIgnoreConsoleError.

Many of our server rendering tests don't use this filter, though,
because it has its own special of asserting warnings.

So I added the warning filter to the server tests, too.

* Deprecate ReactDOM.render and ReactDOM.hydrate

These are no longer supported in React 18. They are replaced by the
`createRoot` API.

The warning includes a link to documentation of the new API. Currently
it redirects to the corresponding working group post. Here's the PR to
set up the redirect: https://github.com/reactjs/reactjs.org/pull/3730

Many of our tests still use ReactDOM.render. We will need to gradually
migrate them over to createRoot.

In the meantime, I added the warnings to our internal warning filter.
2021-06-09 13:46:55 -07:00
Samuel Susla 1a3f1afbd3 [React Native] Fabric get current event priority (#21553)
* Call into Fabric to get current event priority

Fix flow errors

* Prettier

* Better handle null and undefined cases

* Remove optional chaining and use ?? operator

* prettier-all

* Use conditional ternary operator

* prettier
2021-06-08 12:26:21 -04:00
Andrew Clark e6be2d531d Fix tag validation 2021-06-08 11:53:43 -04:00
Andrew Clark 6bbe7c3446 Remove space from tag arguments 2021-06-08 11:40:34 -04:00
Andrew Clark bc7d5ac99d Allow alpha tags 2021-06-08 11:31:42 -04:00
Andrew Clark 48a11a3efc Update next React version (#21647)
This does not mean that a release of 18.0 is imminent, only that the
main branch includes breaking changes.

Also updates the versioning scheme of the `@next` channel to include
the upcoming semver number, as well as the word "alpha" to indicate the
stability of the release.

- Before:       0.0.0-e0d9b28999
- After:        18.0.0-alpha-e0d9b28999
2021-06-08 08:26:22 -07:00
Sebastian Markbåge 5aa0c5671f Fix Issue with Undefined Lazy Imports By Refactoring Lazy Initialization Order (#21642)
* Add a DEV warning for common case

* Don't set Pending flag before we know it's a promise

* Move default exports extraction to render phase

This is really where most unwrapping happen. The resolved promise is the
module object and then we read things from it.

This way it lines up a bit closer with the Promise model too since the
promise resolving to React gets passed this same value.

If this throws, then it throws during render so it's caught properly and
you can break on it and even see it on the right stack.

* Check if the default is in the module object instead of if it's undefined

Normally we'd just check if something is undefined but in this case it's
valid to have an undefined value in the export but if you don't have a
property then you're probably importing the wrong kind of object.

* We need to check if it's uninitialized for sync resolution

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2021-06-07 14:47:18 -07:00