Commit Graph

38536 Commits

Author SHA1 Message Date
David Vacca d69a51a8e9 Introduce kotlin annotation to OptIn into the new Architecture API (#37171)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37171

In this diff I'm introducing a new kotlin annotation to OptIn into the new Architecture API. I named it "NewReactNativeArchitectureExperimentalAPI" but I'm open to name suggestions, maybe make it a bit more generic like:
ReactNativeExperimental?

Ideally it should be named similar to how we are going to publicitize the New Architecture in OSS.

The plan is to use this annotation to mark classes of experimental API, forcing external developers to explicitly optIn into new APIs:

```
UnstableReactNativeAPI
class ReactHost // A class requiring opt-in

// Client code
// this code will compile
OptIn(UnstableReactNativeAPI::class)
fun getReactHost(): ReactHost {
    // ...
    return ReactHost()
}

// This code wont compile
fun getReactHost(): ReactHost {
    // ...
    return ReactHost()
}

```

For more details about OptIn read:
https://kotlinlang.org/docs/opt-in-requirements.html#create-opt-in-requirement-annotations

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D45417255

fbshipit-source-id: f94f85844342a577e5a526b82b7b345470f66ead
2023-05-04 08:58:49 -07:00
Nicola Corti 4c91e8acbb Re-land: Convert RootViewTest to Kotlin (#37250)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37250

This is a re-land of a previous commit which ended up in us losing the history
of the Java file. This new PR should not be doing so.

This is a reference PR on how to convert a JVM Unit test from Java to Kotlin.
A couple of things to keep in mind when converting:
1. Do not use hungarian notation (`mActivity` -> `activity`)
2. JUnit rules need to be annotated with `get:Rule` rather than just `Rule`.
3. Use `import org.powermock.api.mockito.PowerMockito.`when` as whenever`to avoid having to escape all the `when` function invocation in the code as it's a keyword.
4. Do static imports of all the Mockito/PowerMock functions.

Getting rid of PowerMock and using Fakes is a plus, but that's not always possible. Having the test running and be green is already a good result.

Changelog:
[Internal] [Changed] - Convert RootViewTest to Kotlin

Reviewed By: cipolleschi

Differential Revision: D45565375

fbshipit-source-id: 6c01d037e04dc1ec0003263177d86079a6f19a04
2023-05-04 07:56:09 -07:00
Nicola Corti fe5455b87c Back out "Convert RootViewTest to Kotlin" (#37249)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37249

Original commit changeset: e0cf65012665

Original Phabricator Diff: D45526517

I'm reverting this change as the history got lost in this Kotlin conversion. I'm going to re-push it using `hg mv`.

Changelog:
[Internal] [Changed] - Back out "[RN][Android] Convert RootViewTest to Kotlin"

Reviewed By: cipolleschi

Differential Revision: D45564898

fbshipit-source-id: b144f688cfa612f0d22d65cadfd766f73996371c
2023-05-04 07:56:09 -07:00
Max Metral 34d5212f5c Fix Flipper by moving FB_SONARKIT_ENABLED to RCTAppDelegate (#37240)
Summary:
An out-of-the-box react-native init project no longer enables Flipper properly as of 0.72.0-rc1.

## Changelog:

[IOS] [FIXED] Fix Flipper by moving podfile modification of preprocessor def `FB_SONARKIT_ENABLED` from React-Core to React-RCTAppDelegate where it is now used.

Pull Request resolved: https://github.com/facebook/react-native/pull/37240

Test Plan: Generated an app and verified Flipper cannot see the app. Made the modification and generated another app and verified Flipper now sees it and can enable plugins. Verified that runtime (non-test) use of FB_SONARKIT_ENABLED is limited to Libraries/AppDelegate in this project.

Reviewed By: dmytrorykun

Differential Revision: D45563282

Pulled By: cipolleschi

fbshipit-source-id: d760c5ae123cc7c967b19c6c626801d6db28d052
2023-05-04 07:54:01 -07:00
generatedunixname89002005325672 c8a0f19f1a Daily arc lint --take KTFMT
Reviewed By: hick209

Differential Revision: D45561077

fbshipit-source-id: 43c945ca21bccc18ceceb0b8e1ea61564dba0f71
2023-05-04 06:54:53 -07:00
Zihan Chen (MSFT) 4fd8f405be Recognize dictionary type in codegen (#37206)
Summary:
Previously we allow `{[key:string]:Something}` in codegen, `Something` is type-checked but thrown away, generating a `GenericObjectTypeAnnotation`.
In this change, `Something` is added to `GenericObjectTypeAnnotation` as an optional field.
For downstream code such as C++ codegen, this change is **backward compatible**. It allows C++ codegen to produce a more precious type optionally.

## Changelog:

[General] [Added] - Recognize dictionary type in codegen

Pull Request resolved: https://github.com/facebook/react-native/pull/37206

Test Plan:
```
yarn jest react-native-codegen
yarn jest react-native-codegen-typescript-test
```

Reviewed By: cipolleschi

Differential Revision: D45563340

Pulled By: dmytrorykun

fbshipit-source-id: 9a9ce36df6ded6d42d35c3dcb6fb0eaca16c4458
2023-05-04 05:04:12 -07:00
Riccardo Cipolleschi 8c8f7a510f Add example in RNTester to use events with arrays (#37143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37143

This change add an example on how to use events with arrays in the New Architecture in RNTester.

## Changelog:
[Internal] - Add Examples on RNTester on how to send events with arrays from Native to JS

Reviewed By: cortinico

Differential Revision: D45357873

fbshipit-source-id: 812521aad070181759c0a1c76b5e8c628166229c
2023-05-04 04:11:49 -07:00
Riccardo Cipolleschi b422375782 Add support for Arrays in generator (#37145)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37145

This diff adds the generation of Array types in events.

It supports the generation of Array of:
- Boolean
- Int32
- Float
- Double
- String
- Objects
- Array

**Note:** This is a first iteration. We could improve the generation further by leveraging the `Bridging` module within React Native.
I'll take a stab at it in a next diff.

## Changelog:
[General][Added] - Generate events with arrays

Reviewed By: cortinico

Differential Revision: D45321685

fbshipit-source-id: 34b05f5501b06714d1fabf1a51cb057af7027f00
2023-05-04 04:11:49 -07:00
Riccardo Cipolleschi 6168701887 Support Array parsing in events (#37142)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37142

This diff introduce support to parse arrays in events.

We support parsing Arrays of:
- Boolean
- Double
- Float
- Int32
- String Enums
- String
- Objects
- Arrays

## Changelog:
[General][Added] - Add generic support for Arrays in Events parsing

Reviewed By: dmytrorykun, RSNara

Differential Revision: D45268779

fbshipit-source-id: 0c6eae65eb2b41ebf7b47a4cc3e0f0e5fa20d871
2023-05-04 04:11:49 -07:00
Riccardo Cipolleschi 6f75f14883 Revert ENABLE_HERMES_PROFILER flag in cocoapods (#37228)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37228

As discussed offline, the current approach for the Hermes profiler is not the right one.

I'm partially reverting [the commit](https://github.com/facebook/react-native/commit/dce9d8d5de381fe53760ddda0d6cbbdfb5be00e4) which introduced it.

The commit did also a bit of refactoring to improve the quality of the cocoapods scripts we would like to keep.

## Changelog:
[iOS][Removed] - Remove support of Hermes profiler as that's not the right approach.

Reviewed By: cortinico

Differential Revision: D45527507

fbshipit-source-id: acea5f8b610d8b67ee7a6a91993bb8e4592d093f
2023-05-04 03:01:50 -07:00
Nick Gerleman 1cd0f57827 Try to fix MSVC Buck Build (#37242)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37242

X-link: https://github.com/facebook/yoga/pull/1278

Reviewed By: yungsters

Differential Revision: D45552325

fbshipit-source-id: 5687e8ec27a7a70df66e2f89e800210e3ce21ba3
2023-05-04 00:41:12 -07:00
Kevin Gozali 8e1d9a0b75 iOS: deprecate undocumented RCT_ENABLE_LOADING_VIEW, replacing it with RCT_DEV_MENU (#37213)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37213

`RCT_ENABLE_LOADING_VIEW` was added a long time ago with some internal-only use cases that no longer exist today. To avoid confusion, let's deprecate this flag, and re-use RCT_DEV_MENU, which was actually designed for similar dev workflow use cases.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D45509523

fbshipit-source-id: 3d73929ec6811496d26a24f24e8741b43ccbc100
2023-05-03 23:23:10 -07:00
Samuel Susla 523c77da59 Cancel image download when ImageRequest changes (#37223)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37223

changelog: [internal]

Cancel image download when image source changes or <ImageView /> is recycled.

bypass-github-export-checks

Reviewed By: javache

Differential Revision: D45524686

fbshipit-source-id: 515a153ddb214fdce51ff29243b68c5fd5479c64
2023-05-03 22:37:11 -07:00
Samuel Susla 0688458813 Delete ImageRequest::~ImageRequest (#37222)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37222

changelog: [internal]

User defined destructor does not make sense here. ImageRequest is owned by ImageState, which is owned by ImageShadowNode. ImageShadowNode requires garbage collection from the runtime to be destroyed. Calling cancel in dtor is not deterministic and that is undesired.

bypass-github-export-checks

Reviewed By: javache

Differential Revision: D45524705

fbshipit-source-id: 410def2100f479b68682620b2c43071fdfb86715
2023-05-03 22:37:11 -07:00
Samuel Susla 9132d7aad9 Move cancelRequest_ in move ctor in ImageRequest (#37221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37221

changelog: [internal]

Add missing cancelRequest_ std::move.

bypass-github-export-checks

Reviewed By: javache, cortinico

Differential Revision: D45524704

fbshipit-source-id: 1dd0d627549dab353872654d78f7b59d1b2d7174
2023-05-03 22:37:11 -07:00
David Vacca c52f38eb7b Migrate VisibleForTesting to kotlin (#37241)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37241

EZ diff that migrates VisibleForTesting interface to kotlin

There are just 2 files into the annotations package, now both will be written in kotlin

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: cortinico, yungsters

Differential Revision: D45454643

fbshipit-source-id: 7d3ac9f85141f720a201ca81102336e16758ea30
2023-05-03 21:11:37 -07:00
acdlite 43bd29fb22 Gate DevTools test to fix CI (#26742)
Summary:
This test started failing recently in older versions of React because
the Scheduler priority inside a microtask is Normal instead of
Immediate. This is expected because microtasks are not Scheduler tasks;
it's an implementation detail.

I gated the test to only run in v17 because it's a regression test for
legacy Suspense behavior, and the implementation details of the snapshot
changed in v18.

Test plan
x---------

Using latest:

```
yarn test --build --project devtools --release-channel=experimental profilingcache
```

Using v17 (typically runs in a timed CI workflow):

```
/scripts/circleci/download_devtools_regression_build.js 17.0 --replaceBuild
yarn test --build --project devtools --release-channel=experimental --reactVersion 17.0 profilingcache
```

DiffTrain build for commit https://github.com/facebook/react/commit/86b0e91998a04b22bb54a95d54f4a7632efa902f.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45424707

fbshipit-source-id: f3a761984c0ac53b5514f8ff51635bf6c4bab8f6
2023-05-03 18:44:40 -07:00
Phillip Pan 6d886a8d26 get rid of unnecessary weak reference in RCTInstance
Summary:
Changelog: [Internal]

we already had strongSelf captured, just use that instead

Reviewed By: christophpurrer

Differential Revision: D45510817

fbshipit-source-id: fa8a381790392a546c5e5cbe9277cc73f8990c1d
2023-05-03 15:50:19 -07:00
Phillip Pan e9665f0649 get rid of unnecessary nil checks in RCTDevSettings
Summary:
Changelog: [Internal]

these checks do nothing

Reviewed By: christophpurrer

Differential Revision: D45509380

fbshipit-source-id: b3fd01fdbe93a6b0b8b547522a304e61ef4634c5
2023-05-03 15:50:19 -07:00
Phillip Pan 1b741db635 do not expose jsThreadManager from RCTInstance (#37210)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37210

Changelog: [Internal]

no need to expose this

Reviewed By: christophpurrer

Differential Revision: D45507159

fbshipit-source-id: 1467dba09d6359f73996d0d0eeb246eb3f59e96c
2023-05-03 15:46:55 -07:00
Phillip Pan 8c2458e542 rename handleException to handleTaskFault (#37205)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37205

Changelog: [Internal]

so when i was trying to help mdvacca with figuring out what this API does, it was really confusing to grep for since `handleException` is a very common pattern in general. so i'm updating the name here to be more explicit and help us with refactoring later.

bypass-github-export-checks

Reviewed By: mdvacca

Differential Revision: D45501548

fbshipit-source-id: 6ae32328e1117ae81ba53f1742440a68aec38803
2023-05-03 15:43:01 -07:00
Nicola Corti 1be65baf29 Deprecate APIs that are deprecated only on JavaDoc (#37229)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37229

Those methods all have replacements and they have been annotated as `deprecated` but only on the Javadoc level.
The Java compiler from 11 starts to emit warnigns for those functions so I'm actually annotating them with Deprecated correctly.

Changelog:
[Android] [Changed] - Deprecate APIs that are deprecate only on JavaDoc

Reviewed By: mdvacca

Differential Revision: D45525406

fbshipit-source-id: 9fea1a6374c9a14f7f07e5bca8db1221260c03fd
2023-05-03 13:01:02 -07:00
Phillip Pan b07c81268b do not expose logger from RCTHost (#37235)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37235

Changelog: [Internal]

we shouldn't expose the logger, only need to expose the logging information

Reviewed By: javache

Differential Revision: D45513780

fbshipit-source-id: b82496ebcbf87d7f88d6c7e1afea655d4177a0d8
2023-05-03 12:08:19 -07:00
Nicola Corti 71fbb0cea3 Convert RootViewTest to Kotlin (#37227)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37227

This is a reference PR on how to convert a JVM Unit test from Java to Kotlin. A couple of things to keep in mind when converting:

1. Do not use hungarian notation (`mActivity` -> `activity`)
2. JUnit rules need to be annotated with `get:Rule` rather than just `Rule`.
3. Use `import org.powermock.api.mockito.PowerMockito.`when` as whenever`to avoid having to escape all the `when` function invocation in the code as it's a keyword.
4. Do static imports of all the Mockito/PowerMock functions.

Getting rid of PowerMock and using Fakes is a plus, but that's not always possible. Having the test running and be green is already a good result.

Changelog:
[Internal] [Changed] - Convert RootViewTest to Kotlin

Reviewed By: cipolleschi

Differential Revision: D45526517

fbshipit-source-id: e0cf650126659fdc8676fb32e1617ad51ca14e11
2023-05-03 09:25:57 -07:00
Nicola Corti 9030487d33 Do not use deprecated [minSdk|targetSdk]version functions (#37226)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37226

Those functions are deprecated and should be replaced with the properties minSdk and targetSdk.
I'm replacing all of those (apart from the template).

Changelog:
[Internal] [Changed] - Do not use deprecated [minSdk|targetSdk]version functions

Reviewed By: cipolleschi

Differential Revision: D45525922

fbshipit-source-id: dd6c795a669d9760eca3e083e220917916032c2c
2023-05-03 09:16:54 -07:00
Riccardo Cipolleschi d1d8fdf4ca Pass the hermestag file to the read function (#37231)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37231

In a previous diff, we tried to disambiguate between versions of hermes engine by reading the hermestag file.

However, we forgot to pass the file to the `read` function.

It used to work both on main and on CI because that file doesn't exists in those environments. But it failed as soon as we tried to test a release.

## Changelog:
[iOS][Fixed] - Pass the hermestag file to the `read` function.

Reviewed By: dmytrorykun

Differential Revision: D45530010

fbshipit-source-id: 2dcdb77adad375d2e28dd4230ab05dbb85fb82e5
2023-05-03 09:14:40 -07:00
Nicola Corti ab3a2f4ad9 Disable flaky windows test for ReactFabricPublicInstance-test.js (#37216)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37216

Yet another windows flaky test for ReactFabricPublicInstance-test.js which I'm disabling now. It will still run on linux/mac.

Changelog:
[Internal] [Changed] - Disable flaky windows test for ReactFabricPublicInstance-test.js

Reviewed By: cipolleschi

Differential Revision: D45521018

fbshipit-source-id: b37c00d674997e14fd8e12c3f3746f51bcc90669
2023-05-03 08:33:20 -07:00
Nicola Corti 86436270ab Suppress warning on null check due to crash investigation
Summary:
We suspect this null check is actually necessary as we're investigating a crash.
This will silent the warning on this statement

Changelog:
[Internal] [Changed] - Suppress warning on null check due to crash investigation

Reviewed By: blakef

Differential Revision: D45525270

fbshipit-source-id: 692c079bacd15397838cd60146240e9d4e21b1ca
2023-05-03 07:58:29 -07:00
Nicola Corti 93da2c3c6e compileSdkVersion for hermes-engine to 33 (#37225)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37225

Hermes-engine was still building with compileSdkVersion 31. This causes another version of the SDK to be
downloaded on CI making everything slower. This aligns everything to version 33, which is the same version we use
for React Native.

Changelog:
[Internal] [Changed] - compileSdkVersion for hermes-engine to 31

Reviewed By: dmytrorykun

Differential Revision: D45525923

fbshipit-source-id: f7cce527e2378c4e6db6b8b5db865ff3b598bf87
2023-05-03 07:48:56 -07:00
Alex Hunt 5eabbd7067 Set dev menu title to "React Native Dev Menu", add JS executor description (#37195)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37195

Updates the Dev Menu header on Android.

- Small alignment related to D44872456.
- Add subheading label showing current JS executor description (matching iOS) (note: on Android this is unformatted (but informative), e.g. `JSIExecutor+HermesRuntime`).

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D45142924

fbshipit-source-id: 5c95fc85e6d3b6879287440f76165b02957283e5
2023-05-03 04:14:36 -07:00
Nicola Corti ceebab44b4 Update ReactActivityDelegateTest to compile and run with Buck (#37199)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37199

This test `ReactActivityDelegateTest` is written in Kotlin and is not currently
picked up by BUCK. As we look into having more and more tests written in Kotlin,
I'm updating one Kotlin test to be executed correctly within Buck.

Changelog:
[Internal] [Changed] - Update ReactActivityDelegateTest to compile and run with Buck

Reviewed By: philIip, mdvacca

Differential Revision: D45497636

fbshipit-source-id: 7e13902c4f765974c1ff490b657846fb062eb74e
2023-05-03 03:27:17 -07:00
Nicola Corti 0cec0412e5 Bump Robolectric SDK target to 33 (#37200)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37200

Currently Robolectric runs with target SDK 21 on OSS and 33 on Buck internal.
Having those two versions misaligned makes tests harder to maintain, so we should probably re-aling them. Here I bump SDK to 33 + I'm fixing `RootViewTest` which is broken on SDK 33 (both on Gradle and Internal).

Changelog:
[Internal] [Changed] - Bump Robolectric SDK target to 33

Reviewed By: philIip, mdvacca

Differential Revision: D45497430

fbshipit-source-id: 202fb1d7e84362dd74798c026d5a0999d77234ee
2023-05-03 03:27:17 -07:00
Nicola Corti c43ea25267 Remove references to REACT_NATIVE_ROBOLECTRIC_MIRROR (#37201)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37201

As we don't need to have a Robolectric Offline Mirror anymore due to how we execute Robolectric tests only on Gradle/CircleCI or Buck/Internal, we can remove this configuration.

Changelog:
[Internal] [Changed] - Remove references to REACT_NATIVE_ROBOLECTRIC_MIRROR

Reviewed By: philIip, mdvacca

Differential Revision: D45497431

fbshipit-source-id: e26e3117eb456c313dc8bf366bf71bb4dedea048
2023-05-03 03:27:17 -07:00
Nick Gerleman d5dad06b32 Don't export private headers from Buck target (#37127)
Summary:
X-link: https://github.com/facebook/yoga/pull/1269

Pull Request resolved: https://github.com/facebook/react-native/pull/37127

This prevents targets which include Yoga from using its private APIs.

Instances of this have been mostly cleaned up in the past diffs, with the major exception of RN Fabric. To stage this without blocking on that, I added a `yoga-private-api` target for now to keep using these headers while making it unlikely new usages will show up.

Reviewed By: javache

Differential Revision: D45339425

fbshipit-source-id: eb7ef151ad2467d7c3370cd7c10d47e8db9496a0
2023-05-02 18:08:58 -07:00
gnoff 7e6f6aacbb Preinits should support a nonce option (#26744)
Summary:
Currently there is no way to provide a nonce when using
`ReactDOM.preinit(..., { as: 'script' })`

This PR adds `nonce?: string` as an option

While implementing this PR I added a test to also show you can pass
`integrity`. This test isn't directly related to the nonce change.

DiffTrain build for commit https://github.com/facebook/react/commit/b12bea62d9cfd9a925f28cb2c93daeda3865a64e.

Changelog: [Internal]
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45416244

Pulled By: tyao1

fbshipit-source-id: f92d66a1d6358c21e52a3b8003d06c662e2fc9fa
2023-05-02 17:53:35 -07:00
Nick Gerleman 76d01fa42d Cleanup YGValue.h header (#37179)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37179

X-link: https://github.com/facebook/yoga/pull/1273

1. Simplify nan handling a bit
2. Remove string literal operators which seem dead enough to remove. These are public, so anyone could be using them, but it seems like almost nobody is.
    1. FB has no usages of `using namespace facebook::yoga::literals` (exposing the literal operators) outside of Yoga tests.
    1. There is only [a single usage](https://github.com/XITRIX/UIKit/blob/6dfba905ea83c89e255144f7ed90fde8c33ca81a/SDLTest/UIKit.hpp#L19) on GitHub.

Reviewed By: yungsters

Differential Revision: D45419970

fbshipit-source-id: 8121303e5ae66596132a848a711802081728f4fb
2023-05-02 17:08:24 -07:00
Phillip Pan 1bc1a4415f add README for bridgeless mode (#37197)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37197

Changelog: [Internal]

i would like to communicate to OSS that these libraries are not to be used and are undergoing active changes. it seems tricky to enforce this at compile time atm so i think this will be a good first step

we can add stuff later like "what is bridgeless mode" but primary goal is to communicate not to use this

Reviewed By: mdvacca

Differential Revision: D45493984

fbshipit-source-id: 4954068befab71a14899a6bba2069755d17b6a6e
2023-05-02 16:20:48 -07:00
eps1lon f7c3e19d0e Remove unused initialStatus parameter from useHostTransitionStatus (#26743)
Summary:
DiffTrain build for commit https://github.com/facebook/react/commit/efbd68511db472120afa0f3eba78a7462f25ed30.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45410914

Pulled By: tyao1

fbshipit-source-id: 7d7d6cd3f78649856853762fbb7abdb340767ce7
2023-05-02 15:35:13 -07:00
acdlite 076d647747 Fix: Update while suspended fails to interrupt (#26739)
Summary:
This fixes a bug with `use` where if you update a component that's
currently suspended, React will sometimes mistake it for a render phase
update.

This happens because we don't reset `currentlyRenderingFiber` until the
suspended is unwound. And with `use`, that can happen asynchronously,
most commonly when the work loop is suspended during a transition.

The fix is to make sure `currentlyRenderingFiber` is only set when we're
in the middle of rendering, which used to be true until `use` was
introduced.

More specifically this means clearing `currentlyRenderingFiber` when
something throws and setting it again when we resume work.

In many cases, this bug will fail "gracefully" because the update is
still added to the queue; it's not dropped completely. It's also
somewhat rare because it has to be the exact same component that's
currently suspended. But it's still a bug. I wrote a regression test
that shows a sync update failing to interrupt a suspended component.

DiffTrain build for commit https://github.com/facebook/react/commit/18282f881dae106ebf6240aa52c8c02fe7c8d6f2.

Changelog: [Internal]
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: poteto

Differential Revision: D45407314

Pulled By: tyao1

fbshipit-source-id: 1303940cc34db28087563c20a187779a51d133de
2023-05-02 15:35:13 -07:00
acdlite c6b6915c46 Implement experimental_useFormStatus (#26722)
Summary:
This hook reads the status of its ancestor form component, if it exists.

```js
const {pending, data, action, method} = useFormStatus();
```

It can be used to implement a loading indicator, for example. You can
think of it as a shortcut for implementing a loading state with the
useTransition hook.

For now, it's only available in the experimental channel. We'll share
docs once its closer to being stable. There are additional APIs that
will ship alongside it.

Internally it's implemented using startTransition + a context object.
That's a good way to think about its behavior, but the actual
implementation details may change in the future.

Because form elements cannot be nested, the implementation in the
reconciler does not bother to keep track of multiple nested "transition
providers". So although it's implemented using generic Fiber config
methods, it does currently make some assumptions based on React DOM's
requirements.

DiffTrain build for commit https://github.com/facebook/react/commit/540bab085d571789f4562565eebfd0db9f36345c.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: poteto

Differential Revision: D45332971

Pulled By: tyao1

fbshipit-source-id: 12e2b5a6c71fc78efb8aedfd1907f65a816cc289
2023-05-02 15:35:13 -07:00
acdlite d777e3f0c2 Fix: Resolve entangled actions independently (#26726)
Summary:
When there are multiple async actions at the same time, we entangle them
together because we can't be sure which action an update might be
associated with. (For this, we'd need AsyncContext.) However, if one of
the async actions fails with an error, it should only affect that
action, not all the other actions it may be entangled with.

Resolving each action independently also means they can have independent
pending state types, rather than being limited to an `isPending`
boolean. We'll use this to implement an upcoming form API.

DiffTrain build for commit https://github.com/facebook/react/commit/6eadbe0c4aebf68410bb48147054ee22eec4c20c.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: poteto

Differential Revision: D45301261

Pulled By: tyao1

fbshipit-source-id: e571d306be12f184c98ad7c24ff1ec1dbf788056
2023-05-02 15:35:13 -07:00
David Vacca 99f88ce33b EZ refactor to remove lint warns and move to java 8 apis (#37170)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37170

EZ refactor to remove lint warns

changelog: [internal] internal

Reviewed By: philIip

Differential Revision: D45378239

fbshipit-source-id: 3a9c80976e10dce8491d5cff3abaa394bad18f97
2023-05-02 12:31:11 -07:00
David Vacca 3f7c2b2215 EZ refactor of bridgless classes (#37168)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37168

EZ refactor of bridgless classes removing lint warns and moving to java 8

changelog: [internal] internal

Reviewed By: philIip

Differential Revision: D45378241

fbshipit-source-id: 37cc2c575ced12d007bd00623c85696a735eb2c6
2023-05-02 12:31:11 -07:00
Pranav Yadav 8a49754cda Refactor: JS substr() is deprecated, using slice() instead (#37136)
Summary:
Fixes: https://github.com/facebook/react-native/issues/37135

- `substr()` is not part of the core JS since ~2018
- No wonder why no one noticed this :)
- Though its supported by modern browsers, its deprecated
- Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

### Why `slice()` and not `substring()`?
> Beacuse I like pizza ;) jk

The reason, that I'm not using the most obvious alternative `substring()` is;
- It _swaps the args_ passed, when; `startIndex > endIndex` —which I think is not a property of _good_ fn
  and also does not reflects the same in it's name.
- It _doesn't support negative args_, which I think reduces flexibility to work with it.
- It could lead to more bugs in most of the cases.

### Refecrences:
- Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring#differences_between_substring_and_slice
- Ref. for `slice()`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice
- Ref. for `substring()`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring

## Changelog:

[GENERAL][FIXED] - Refactor: `substr()` is deprecated, using `slice()` instead across RN codebase

Pull Request resolved: https://github.com/facebook/react-native/pull/37136

Test Plan: - `yarn lint && yarn flow && yarn test-ci` --> _should be green_

Reviewed By: christophpurrer

Differential Revision: D45477910

Pulled By: jacdebug

fbshipit-source-id: 96a80893477599b9a549918924157627b9b0c3f4
2023-05-02 11:28:56 -07:00
Dmitry Rykun bffb307fdb Remove duplicate function prototype (#37194)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37194

`convertObjCObjectToJSIValue` function prototype is declared in `RCTTurboModule.h`. This diff removes its duplicate declaration from `RCTTurboModule.m`.
Changelog: [Interanal]

Reviewed By: cipolleschi

Differential Revision: D45483572

fbshipit-source-id: bc1edae7e08b5345281134ebfe9d0cbdfedcf581
2023-05-02 10:20:11 -07:00
Dmitry Rykun 9f496e2be5 Make sure that hermes-engine is updated with cocoapods. (#37148)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37148

This should fix https://github.com/facebook/react-native/issue/36945, which is also causing annoyance when doing the releases

## Changelog:
[iOS][Changed] - Use contents of sdks/.hermesversion to let cocoapods recognize Hermes updates.

Reviewed By: cipolleschi

Differential Revision: D45394241

fbshipit-source-id: 972fbee8f954b90f7087bb232f922761c1639e06
2023-05-02 09:14:48 -07:00
tarunrajput 849470702f Codegen 118: add throwIfBubblingTypeisNull in error-utils and use it in events (#37191)
Summary:
part of codegen Issue https://github.com/facebook/react-native/issues/34872

> Extract the code that throws if argumentProps are null in a throwIfBubblingTypeisNull function in the error-utils.js file. Use it in the [flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L244-L246) and in the [typescript/components/event.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L232-L233) files

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal][Changed]: Add throwIfBubblingTypeisNull in error-utils and use it in events

Pull Request resolved: https://github.com/facebook/react-native/pull/37191

Test Plan: `yarn jest react-native-codegen`

Reviewed By: cipolleschi

Differential Revision: D45478073

Pulled By: dmytrorykun

fbshipit-source-id: f70ce3f32d93170cafcea9c8b8c2ba06e760fa37
2023-05-02 09:12:10 -07:00
Eric Rozell 042179a742 Replace 'React' with 'react' in rntester examples (#37185)
Summary:
React Native macOS:
Please note, I do not plan to

Pull Request resolved: https://github.com/facebook/react-native/pull/37185

Updates a few imports in RNTester to 'react' as we had previously done in:
https://github.com/facebook/react-native/commit/0ee5f689

Changelog: [Internal]

Reviewed By: jacdebug

Differential Revision: D45445211

fbshipit-source-id: 7d345a874bd8b99ddb11ebb5385c2a07330a6531
2023-05-02 08:21:34 -07:00
Dmitry Rykun 4568e8f477 Refactor hasComponent binding so it uses bridging API (#37150)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37150

This diff should simplify binding of `__nativeComponentRegistry__hasComponent`.

Changelog: [Internal] - Simplify `hasComponent` binding by using bridging API.

Reviewed By: javache

Differential Revision: D45150027

fbshipit-source-id: 6d7ee09af3d4d64392f5ddf0f4cf46d77d3fc878
2023-05-02 04:36:54 -07:00
Nick Gerleman 76a42c292d Remove "auto" from YGFloatOptional conversion (#37186)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37186

"auto" is not a valid value to go into anything accepting `YGFloatOptional`. Remove the code here which special cases it (though we will produce the same result). Also remove error logging which is not localized/useful, in the theme of having user style inputs be handled gracefully.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D45434650

fbshipit-source-id: e83b3f5d84cf1186c67ca3a546cf2a48b09fc1e8
2023-05-02 01:28:45 -07:00