Commit Graph

26 Commits

Author SHA1 Message Date
Christoph Nakazawa 4148976a83 Use `invariant` instead of `fbjs/lib/invariant`
Summary: This is one more step to remove `fbjs` from `react-native-github`. This changes both the internal and external code to use `invariant` from zertosh instead of the copy in fbjs.

Reviewed By: yungsters

Differential Revision: D13195941

fbshipit-source-id: 73564ca1715110e7da9c7ef56dc57374d61377e0
2018-12-03 00:07:02 -08:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Eli White d01ab66b47 Prettier React Native Libraries
Reviewed By: sahrens

Differential Revision: D7961488

fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
2018-05-10 19:10:38 -07:00
Brent Erickson f99ca3c03f Fix a race condition in AppState that prevents listeners from being notified
Summary:
If someone has setup a subscription on AppState and we correct AppState via getCurrentAppState call, we need to notify all the subscribers of AppState.
1 ) Initial AppState.currentState = 'active'
2-start) Subscribe to AppState Changes
3-start) Fetch Current AppState
4 ) App Code subscribes to AppState module
5 ) App becomes backgrounded
2-finish) AppState listeners are setup (missing background event)
3-finish) AppState.currentState updated to background

At this point the subscription setup in 4) will never be called with the change.

AppState should always call subscribers on change

This is very difficult to formally test since it's due to a race condition. We've seen this condition via bug reports but have had no local repro.

[GENERAL][BUGFIX][AppState] - Fix a race condition that could prevent AppState subscription change listener from firing on initial launch
Closes https://github.com/facebook/react-native/pull/18236

Differential Revision: D7823370

Pulled By: hramos

fbshipit-source-id: 99b174df70262ceaf9da141d005131facd624594
2018-04-30 18:01:17 -07:00
Rubén Norte d5e9e55fa3 Remove @providesModule from all modules
Summary:
This PR removes the need for having the `providesModule` tags in all the modules in the repository.

It configures Flow, Jest and Metro to get the module names from the filenames (`Libraries/Animated/src/nodes/AnimatedInterpolation.js` => `AnimatedInterpolation`)

* Checked the Flow configuration by running flow on the project root (no errors):

```
yarn flow
```

* Checked the Jest configuration by running the tests with a clean cache:

```
yarn jest --clearCache && yarn test
```

* Checked the Metro configuration by starting the server with a clean cache and requesting some bundles:

```
yarn run start --reset-cache
curl 'localhost:8081/IntegrationTests/AccessibilityManagerTest.bundle?platform=android'
curl 'localhost:8081/Libraries/Alert/Alert.bundle?platform=ios'
```

[INTERNAL] [FEATURE] [All] - Removed providesModule from all modules and configured tools.
Closes https://github.com/facebook/react-native/pull/18995

Reviewed By: mjesun

Differential Revision: D7729509

Pulled By: rubennorte

fbshipit-source-id: 892f760a05ce1fddb088ff0cd2e97e521fb8e825
2018-04-25 07:37:10 -07:00
Mats Byrkeland edb6ca72fd Fix ESLint warnings using 'yarn lint --fix'
Summary:
Hi! I would like to contribute to React Native, and I am just starting out. I forked the repo and found that it has quite a lot of ESLint warnings – many of which were automatically fixable. This PR is simply the result of running `yarn lint --fix` from the root folder.

Most changes are removing trailing spaces from comments.

Haven't really done any manual testing, since I haven't done any code changes manually. `yarn test` runs fine, `yarn flow` runs fine, `yarn prettier` is satisfied.

N/A

[INTERNAL][MINOR][] - Fix ESLint warnings
Closes https://github.com/facebook/react-native/pull/18047

Differential Revision: D7054948

Pulled By: hramos

fbshipit-source-id: d53e692698d1687de5821c3fb5cdb76a5e03b71e
2018-02-22 07:23:17 -08:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Héctor Ramos 79e24ede40 Migrate additional docs to the new format
Summary:
[DOCS]
Closes https://github.com/facebook/react-native/pull/16874

Differential Revision: D6375515

Pulled By: hramos

fbshipit-source-id: 64359b45a37c7b478919121573ca04dbb1ce6609
2017-11-20 13:16:12 -08:00
Eric Rozell 809f1e97de Avoid race condition for AppState.currentState
Summary:
When the AppState module is initialized, it subscribes to the `appStateDidChange` event and sends an async native method call to the AppState native module. There is a small race condition window where the native module can read the current app state as `uninitialized` before calling the JavaScript callback, and then be interrupted by the underlying mechanism to trigger the `appStateDidChange` event. If the `appStateDidChange` event is processed before the JavaScript callback, the resulting value of `AppState.currentState` will be invalid.

Fixes Microsoft/react-native-windows#1300

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)

I simulated (over-exaggerated) the race condition by injecting "thread sleep" calls in the native method call and the native mechanism for updating the app state.

I then ran the AppStateExample in the RNTester and found that the current app state was set to `uninitialized`, as opposed to the expected value of `active`.

Once I made this JavaScript change, the over-exaggerated race condition no longer resulted in an invalid app state.
Closes https://github.com/facebook/react-native/pull/15499

Differential Revision: D5660620

Pulled By: hramos

fbshipit-source-id: 47c0dca75d37f677191c48f2148a72edd9cdd0e2
2017-08-18 13:14:59 -07:00
Alex Dvornikov a93b7a2da0 Added stubs for some native modules
Reviewed By: javache

Differential Revision: D5111649

fbshipit-source-id: eef2f84556611dec01978d845b89fa145ec5d4db
2017-06-01 08:31:19 -07:00
Dan Abramov a5ea974948 Fix the website build
Summary:
118e88393e broke autodoc generation because autodoc isn't smart enough to understand some patterns.

I'm working around it by using the same trick as this file was using previously: reassigning the class variable.

Similarly, using a property initializer produces bad output so I had to remove it:

<img width="146" alt="screen shot 2017-02-20 at 19 00 36" src="https://cloud.githubusercontent.com/assets/810438/23138561/09ebb476-f7a0-11e6-8fad-92c5a01503c3.png">

cc ericnakagawa mkonicek for review
Closes https://github.com/facebook/react-native/pull/12479

Differential Revision: D4591285

Pulled By: gaearon

fbshipit-source-id: 5884620a08874298b1b2c810e8fb769eba4e1199
2017-02-21 09:11:01 -08:00
Dan Abramov 118e88393e Guard against missing native module
Reviewed By: martinbigio

Differential Revision: D4579114

fbshipit-source-id: a2e9f634748e1c56eb9867bfb9e3e66e9cdc5e93
2017-02-17 10:07:01 -08:00
Héctor Ramos 86684a0a29 docs(AppState.js): update example to ES6
Summary:
If this is the way to go, I'll update the rest of the document :)

> Explain the **motivation** for making this change. What existing problem does the pull request solve?

- Update basic usage to latest ES6-7 syntax
- Provide a working simple example of using AppState
Closes https://github.com/facebook/react-native/pull/11879

Differential Revision: D4443891

Pulled By: hramos

fbshipit-source-id: 87433e994ee56050e24a3853f24a94b54f5586d4
2017-01-23 11:58:33 -08:00
Satyajit Sahoo fa5ad85252 Remove deprecated APIs and modules
Summary:
We've deprecated these APIs for quite a few releases and we should be able to get rid of them now.

Remove following deprecated modules/components
 - AppStateIOS
 - ActivityIndicatorIOS
 - IntentAndroid
 - SliderIOS
 - SwitchAndroid
 - SwitchIOS
 - LinkingIOS

Update following modules to remove callback support
 - Clipboard
 - NetInfo

cc bestander
Closes https://github.com/facebook/react-native/pull/9891

Reviewed By: bestander

Differential Revision: D3974094

Pulled By: javache

fbshipit-source-id: 9abe32716bd85d0cea9933894f4447d53bdd5ee7
2016-10-11 07:43:52 -07:00
David Aurelio 94666f16c7 Auto-fix lint errors
Reviewed By: bestander

Differential Revision: D3683952

fbshipit-source-id: 9484d0b0e86859e8edaca0da1aa13a667f200905
2016-08-09 06:43:46 -07:00
Adam Comella 68b0ce657e iOS: Provide correct initial value for AppState.currentState
Summary:
Attempt to fix #7919.

Currently, if the app is launched into the background and you read `AppState.currentState` too soon, you will see the value `'active'` instead of `'background'`. This is because the default value of `AppState.currentState` is hardcoded to be `'active'` and it is initialized with the actual value asynchronously.

This attempts to fix the bug by having the `RCTAppState` module provide the initial state as a module constant.

As noted in #7919, it looks like this fix was already tried and reverted with 0fb3d8de83. zjj010104, hedgerwang, nicklockwood -- can you explain why? I would very much like to get this bug fixed. Nobody has followed up on the issue I filed so I decided to just go ahead and make a PR with my best guess at a fix.

**Test plan (required)**

Built a small app as described in the repro steps for #7919 and verified that, when the app is launched into the background, `init currentState: background` is printed. Also verified that  `i
Closes https://github.com/facebook/react-native/pull/8058

Differential Revision: D3554619

fbshipit-source-id: 5d950b85e335765552bbd3cf6ed91534062e35a1
2016-07-12 23:28:22 -07:00
Nick Lockwood d9737571c4 Updated AppState module to use new emitter system
Summary: AppState now subclasses NativeEventEmitter instead of using global RCTDeviceEventEmitter.

Reviewed By: javache

Differential Revision: D3310488

fbshipit-source-id: f0116599223f4411307385c0dab683659d8d63b6
2016-05-23 09:13:37 -07:00
David Aurelio ad8a335864 Remove knowledge of fbjs from the packager
Summary:Follow-up to https://github.com/facebook/react-native/pull/5084

This…
- changes all requires within RN to `require('fbjs/lib/…')`
- updates `.flowconfig`
- updates `packager/blacklist.js`
- adapts tests
- removes things from `Libraries/vendor/{core,emitter}` that are also in fbjs
- removes knowledge of `fbjs` from the packager

Closes https://github.com/facebook/react-native/pull/5084

Reviewed By: bestander

Differential Revision: D2926835

fb-gh-sync-id: 2095e22b2f38e032599d1f2601722b3560e8b6e9
shipit-source-id: 2095e22b2f38e032599d1f2601722b3560e8b6e9
2016-03-02 04:28:38 -08:00
Martin Konicek 679beb2a3a Tweak docs before releasing 0.19
Reviewed By: mkonicek

Differential Revision:D2883844
Ninja: Only docs and React Native website, doesn't affect any fb apps

fb-gh-sync-id: 4bf56dc695224f172832ca5381cebceab9e5fe4f
2016-01-30 17:11:28 -08:00
Sokovikov c2d75d7a65 Android AppState
Summary: Closes https://github.com/facebook/react-native/pull/5152

Reviewed By: svcscm

Differential Revision: D2850250

Pulled By: mkonicek

fb-gh-sync-id: 0b5063fa7121d4e304a70da8573c9ba1d05a757c
2016-01-21 11:47:21 -08:00
Christopher Chedeau 2d50d920fa Updates from Tue 24 Mar
- [ReactNative] Open Source PushNotifications and move Badge Number methods and permission into it | Tadeu Zagallo
- [react-packager] Fix regression with transform errors | Amjad Masad
- Flowify TextStylePropTypes and fix a bug with unsupported props | Marshall Roch
- [ReactNative] Remove `arc build` instructions from require | Alex Kotliarskyi
- Flowify Library/Utilities/ | Marshall Roch
- [react-packager] Default to index.js from main if it's a dir | Amjad Masad
2015-03-24 09:26:16 -07:00
Christopher Chedeau 5baffa03fd Second Updates from Mon 23 Mar
- [ReactNative] Use deprecated ix in TabBarExample | Amjad Masad
- [ReactNative] Expanded license on obj-c files | Christopher Chedeau
- [ReactNative] Expanded license on js files | Christopher Chedeau
- [ReactNative] Fix React Devtools integration | Alex Kotliarskyi
- [Text] Account for font leading so descenders are not clipped | James Ide
- [ReactNative] Expanded license on js packager files | Christopher Chedeau
- more UIExplorer flow | Basil Hosmer
- [react-packager] Pick up package changes while running | Amjad Masad
- Added a graph view and a ReactNative metric that displays current queue and execution time for the JS thread. | Bryce Redd
- [ReactNative] Add NativeModules and DeviceEventEmitter to react-native exports | Alex Kotliarskyi
2015-03-23 15:07:33 -07:00
Christopher Chedeau 06a87bec25 Updates from Wed 18 Mar
- [ReactNative] Add AsyncStorageTest | Spencer Ahrens
- [ReactNative] Add timers integration test | Spencer Ahrens
- [ReactNative] Remove ExpandingText | Tadeu Zagallo
- [TouchableHighlight] Preserve underlay style when restoring inactive props | Christopher Chedeau
- clean flow errors in react-native-github | Basil Hosmer
- [ReactNative] Sort React Native exports into two groups, Components and APIs | Christopher Chedeau
- [ReactNative] Rename Slider to SliderIOS | Tadeu Zagallo
- [react_native] JS files from D1919491: Improve JS logging | Martin Kosiba
- [ReactNative] Add TimerExample | Spencer Ahrens
- [RFC][ReactNative] increase timer resolution | Spencer Ahrens
- [ReactNative] Strip prefixes from NativeModules keys | Spencer Ahrens
- [ReactNative] Small docs cleanup in ActivityIndicatorIOS and DatePickerIOS | Christopher Chedeau
- [ReactNative] Improvements on perf measurement output | Jing Chen
- [ReactNative] Clean up Touchable PropTypes | Christopher Chedeau
- [ReactKit] Fail tests when redbox shows up | Alex Kotliarskyi
2015-03-18 15:57:49 -07:00
Christopher Chedeau f7cf017d29 Updates from Tue 17 Mar
- [ReactNative] Remove pushNotification prop from renderApplication | Eric Vicenti
- [react_native] Stub VibrationIOS on Android | Andy Street
- [ReactNative] Simplify and test interpolators | Christopher Chedeau
- [ReactNative] Increase timeout for obj-c tests | Christopher Chedeau
- [ReactNative] Updated RKText to new UIManager system | Nick Lockwood
- [ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule | Nick Lockwood
- [ReactKit] Remove NativeModulesDeprecated | Spencer Ahrens
- [ReactNative] Allow single callbacks in NativeModules | Spencer Ahrens
- [ReactNative] s/RK/RCT in OSS | Spencer Ahrens
- [ReactNative] Cleanup StyleSheet API | Christopher Chedeau
- [RCTVibration] Basic Vibration API | Christopher Chedeau
- [React Native] Prevent crash in redbox code with two thrown errors | Ben Alpert
- [ReactNative] unbreak Android | Andrew Rasmussen
2015-03-17 13:43:53 -07:00
Christopher Chedeau 2b66b21c95 Updates from Mon 16 Mar
- [ReactNative] Share same server port for debugger proxy | Alex Kotliarskyi
- [react-packager] small fixes to image loader | Amjad Masad
- [ReactNative] NetworkInformation.reachability API w/ example | Eric Vicenti
- [ReactNative] Put launchOptions in RCTPushNotificationManager | Andrew Rasmussen
- [ReactNative] Improve PixelRatio documentation | Christopher Chedeau
2015-03-16 19:01:28 -07:00
Christopher Chedeau 642c13e3e3 Updates from Thu Mar 12
- Fixed sticky section headers in ListView | Nick Lockwood
- [ReactNative] AppState cleanup, remove Subscribable, add in OSS examples | Eric Vicenti
- [react-packager] package.json cleanup (seperate packager into it's own package) | Amjad Masad
- [ReactNative] Move PushNotificationIOS to oss | Tadeu Zagallo
- [ReactNative] Fix shake gesture after RedBox is dismissed | Alex Kotliarskyi
- [catlyst|madman] fix prop type warning | Jiajie Zhu
- [ReactNative] Remove Subscribable from TextInput | Eric Vicenti
- Unforked ExceptionsManager, AlertManager and AppState | Nick Lockwood
- [ReactNative|MAdMan] Notification Subscribable | Eric Vicenti
- [ReactNative] OSS AsyncStorage with example | Spencer Ahrens
2015-03-12 12:51:44 -07:00