Commit Graph
14266 Commits
Author SHA1 Message Date
郭帅彬andAndrew Clark e628aede4e fix: maxYieldInterval should not compare with currentTime directly in Scheduler-shouldYieldToHost 2021-06-30 10:01:04 -04:00
Sebastian SilbermannandGitHub 4e1fdbbe32 chore: Ignore build2/ when linting (#21204) 2021-06-30 14:27:32 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
bb79d93250 Bump ws from 6.1.2 to 6.2.2 in /scripts/release (#21628)
Bumps [ws](https://github.com/websockets/ws) from 6.1.2 to 6.2.2.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/commits)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 16:53:39 -04:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
f1015b6885 Bump ecstatic from 2.2.1 to 2.2.2 in /scripts/bench (#20468)
Bumps [ecstatic](https://github.com/jfhbrook/node-ecstatic) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/jfhbrook/node-ecstatic/releases)
- [Changelog](https://github.com/jfhbrook/node-ecstatic/blob/2.2.2/CHANGELOG.md)
- [Commits](https://github.com/jfhbrook/node-ecstatic/compare/2.2.1...2.2.2)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-29 16:53:31 -04:00
Brian VaughnandGitHub 78f9773c62 Updated scripts and config to replace "master" with "main" branch (#21768) 2021-06-29 14:26:24 -04:00
Andrew ClarkandGitHub c2dfa0c9e9 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 ClarkandGitHub ebc2bf6943 act: Add test for bypassing queueMicrotask (#21743)
Test for fix added in #21740
2021-06-25 12:39:46 -07:00
Brian VaughnandGitHub 89fcb7442c 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 AbramovandGitHub ec9685a3e5 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 AbramovandGitHub a0b513c137 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 VaughnandGitHub c7ac19663e DevTools: Fix Settings dialog scroll/size bug in Firefox (#21747) 2021-06-24 11:19:57 -04:00
Dan AbramovandGitHub f2a58d67cd 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 ClarkandGitHub d1ea706d95 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 VaughnandGitHub 35f7452276 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 AbramovandGitHub 2760dfd868 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 VaughnandGitHub 1bceb811f0 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 ClarkandGitHub 66bcc9758c 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 ClarkandGitHub b81a551f62 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 ClarkandGitHub 12c325f31f 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ågeandGitHub e550e9686d 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 AbramovandGitHub addbfd9670 Fix failing test (#21697) 2021-06-17 13:56:18 +01:00
49fea2386e Fix for failed Suspense layout semantics (#21694)
Co-authored-by: Dan Abramov <[email protected]>
2021-06-16 19:44:44 -04:00
Andrew ClarkandGitHub 2fbb954846 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 156de388af Fix fixture lockfile manually 2021-06-16 00:04:01 +01:00
Dan Abramov 81806d1859 Add missing package lock 2021-06-15 23:52:15 +01:00
Dan Abramov 4a3990660d Remove unused variable 2021-06-15 23:49:41 +01:00
Dan Abramov 4f87e7a951 Use npm lockfile for fixture 2021-06-15 23:49:04 +01:00
Dan AbramovandGitHub 6758e9f821 [SSR2 Fixture] Update APIs (#21688) 2021-06-15 23:20:51 +01:00
Sebastian MarkbågeandGitHub 55d5169729 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ågeandGitHub d0e611f699 Merge /unstable-fizz entry point into /server (#21684) 2021-06-14 18:37:44 -07:00
Sebastian MarkbågeandGitHub 4e54594aac 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ågeandGitHub 950dae4e27 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ågeandGitHub 955ae55529 [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ågeandGitHub 071c15f526 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 AbramovandGitHub 16a2cba41b Remove invokeGuardedCallback from commit phase (#21666)
* Remove invokeGuardedCallback from commit phase

* Sync fork
2021-06-14 21:45:53 +01:00
Sebastian MarkbågeandGitHub b0ad75edf9 [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 AbramovandGitHub ce91f95720 Set deletedTreeCleanUpLevel to 3 (#21679) 2021-06-14 20:10:24 +01:00
Dan AbramovandGitHub 0f596500dc Wrap eventhandle-specific logic in a flag (#21657) 2021-06-11 21:08:32 +01:00
Brian VaughnandGitHub b3d8093a46 Update react_18.md 2021-06-11 14:27:09 -04:00
Brian VaughnandGitHub dbed62591d Update react_18.md 2021-06-11 14:25:47 -04:00
Brian VaughnandGitHub e9b3543d2e Update react_18.md 2021-06-11 14:24:09 -04:00
Brian VaughnandGitHub 3ae4d66c61 Update react_18.md 2021-06-11 14:22:57 -04:00
Brian VaughnandGitHub d3d8f83a68 Added React 18 issue template 2021-06-11 14:19:37 -04:00
Brian VaughnandGitHub 8b979898fd DevTools can inspect Proxies that return broken iterator functions (#21660) 2021-06-11 10:15:48 -04:00
Timothy YungandGitHub 6c005e24ca Export React Native AttributeType Types (#21661) 2021-06-11 00:45:49 -07:00
Sebastian MarkbågeandGitHub b3f8835ed8 Revert "Make enableSuspenseLayoutEffectSemantics static for www (#21617)" (#21656)
This reverts commit 637d5ccbd9.
2021-06-10 10:12:31 -07:00
Samuel SuslaandGitHub 8ffe12f8fe 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 ClarkandGitHub 6038150703 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 SuslaandGitHub 4b36f79b6a [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 be66e3f356 Fix tag validation 2021-06-08 11:53:43 -04:00