Commit Graph

93 Commits

Author SHA1 Message Date
Wayne Cheng f536a0c268 Adding flow strict local to remaining possible files in xplat/JS
Summary:
ag -L --ignore __snapshots__ 'flow strict|noflow|generated|The controller you requested could not be found.' | ag '\.js$' | xargs ag -l 'flow' | sort > ~/temp
  cat ~/temp | xargs ag -L 'flow strict' | xargs sed -i '' 's/flow$/flow strict-local/'
  until flow check; do flow check --json | jq -r '.errors[].message[0].path' | sort | uniq | xargs hg revert; done

allow_many_files
The controller you requested could not be found.
The controller you requested could not be found.

Reviewed By: TheSavior

Differential Revision: D9004573

fbshipit-source-id: 936bd5741706b781be06bf08b6ad805a69407dfd
2018-08-09 08:54:44 -07:00
Eli White 370e0db970 Move View native require call to new file
Summary: Moving out the requireNativeComponent call into a new file. We want this long term for all of our view managers to support codegen of the native side and so we can move the viewConfigs into JS.

Reviewed By: yungsters

Differential Revision: D9231619

fbshipit-source-id: 7c89587cc6a76e92b309c4941577291e56af8c7c
2018-08-08 18:46:53 -07:00
Spencer Ahrens 76eebce3c2 Fix more forwardRef displayNames
Summary:
See https://reactjs.org/docs/forwarding-refs.html#displaying-a-custom-name-in-devtools

reapply of D8342904

Reviewed By: yungsters

Differential Revision: D8465006

fbshipit-source-id: f196f39b9b1c9bbe16a845667ebbdb21953a5848
2018-06-19 14:17:19 -07:00
Spencer Ahrens ddf2c2ffd6 fix forwardRef displayName on Text and View
Reviewed By: TheSavior

Differential Revision: D8342852

fbshipit-source-id: 5af80edfd5de5b6d6ea6fdc24abf8931f767c812
2018-06-11 19:22:51 -07:00
Tim Yung 8dc3ba0444 RN: Remove Native Prop Validation
Summary:
As we migrate over to static typing solutions for props, we cannot rely on always having `propTypes` available at runtime.

This gets us started on that journey by removing the native prop validation that happens when we require native components.

bypass-lint

Reviewed By: TheSavior

Differential Revision: D7976854

fbshipit-source-id: f3ab579a7f0f8cfb716b0eb7fd4625f8168f3d96
2018-06-01 12:54:14 -07:00
Tim Yung de11ba2a5e RN: Fix Type for ReactNative.NativeComponent (1/2)
Reviewed By: TheSavior

Differential Revision: D7984814

fbshipit-source-id: 0097819128b7f82267bceeb9d5e1b5057c5129ec
2018-05-13 01:05:56 -07:00
Tim Yung 6a1b41643a RN: Consistently Throw for <Text><View /></Text>
Reviewed By: sahrens

Differential Revision: D7898238

fbshipit-source-id: a2b74e691a116b1beae3c6bb266252a722aacbb1
2018-05-09 01:16:11 -07:00
Tim Yung 3e534b9aab RN: Switch `View` to `React.forwardRef`
Reviewed By: bvaughn, sophiebits

Differential Revision: D7896711

fbshipit-source-id: c10c8a14a00ac2d67605e6e4fe1a341b4688fdd8
2018-05-09 01:16:11 -07:00
Tim Yung e1339bc183 RN: Replace `context.isInAParentText` w/ React.createContext
Reviewed By: sahrens

Differential Revision: D7895382

fbshipit-source-id: 4affcecd147b8e8c506e0d94f223bac3e6dfdf66
2018-05-09 01:16:11 -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
Eli White 26734a8473 Migrating View to be a Flow Typed ES6 class
Summary:
The flow type for View using createReactClass was essentially `any`, allowing any Prop to be passed in, only pseudo enforced at run time via propTypes.

This diff converts View away from createReactClass and instead uses ReactNative.NativeComponent. This was previously typed as any as well which didn't buy us much. This change converts View to be an ES6 React class component to ensure proptypechecking, and exposes the methods copied from NativeMethodsMixin.

Reviewed By: yungsters

Differential Revision: D5933888

fbshipit-source-id: eae63b818203e0e86741f9f154ec9cf3498369e2
2018-03-09 18:33:52 -08:00
Eli White 5035af80ec Tightening types for View and VirtualizedList
Reviewed By: yungsters

Differential Revision: D7215391

fbshipit-source-id: fa144c0dc3fd897864403b589e943ea88e78a999
2018-03-09 15:11:46 -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
Valentin Shergin 52648326e6 Generalization of `isInAParentText` context
Summary:
Currently `isInAParentText` context works as imaginary `isInAAncestorText` context (not like a real `isInAParentText`).
Let's imagine we have hierarchy like:
`View -> Text -> Text* -> View* -> Text* -> Text* -> View*`
With current implementation all nodes marked with asterisk have `isInAParentText` context, which is incorrect (because some of them actually in View context).

With the new implemetations it will work like this:
`View -> Text -> Text* -> View* -> Text -> Text* -> View*`
So, only nodes which have <Text> (or <TextInput>) as a parent will have `isInAParentText` context.

This change allows to select proper `Text` vs. `VirtualText` component in cases where <Text> and <View> components can interleave each other.

Reviewed By: sahrens

Differential Revision: D6690495

fbshipit-source-id: f7c59b23d0eaf68a1d08036b858d99c9547f7878
2018-01-14 20:03:32 -08:00
Valentin Shergin a5af841d25 Prettier for View, Image and co.
Summary: Trivial beauty.

Reviewed By: sahrens

Differential Revision: D6715955

fbshipit-source-id: 3632750591f53d4673a2ce76309a0cc62946524d
2018-01-14 20:03:32 -08:00
Héctor Ramos 64d80b13db Migrate to new documentation format
Summary:
Now that the Component and API docs are no longer auto-generated, we need to consolidate on a new format for our jsdoc comments. Any help from the community will be appreciated.

In this initial pull request, we'll be tackling the following docs:

- `AccessibilityInfo`, an API doc.
- `ActivityIndicator`, a Component doc.
- `View`, a Component doc.

This top comment will serve as a style guide, and when in doubt, please refer to the individual commits in this PR.

Each commit should update a single component or API, along with any relevant markdown files.

- Documentation in the JavaScript source files should be succinct. Any verbosity should be moved over to the markdown docs in the website...
- ...by adding a link to the relevant method/prop on the website to every comment block.
- Avoid markdown style links in JavaScript source files, opt for plain old URIs.

Let code document itself:

- If a method is Flow typed, the comment block does not need to repeat this information.
- If a param can be one of several values, and the type definition is easily determined from the code, the values should not be repeated in the comment block. Again, move this to the markdown doc if not present already.
Closes https://github.com/facebook/react-native/pull/16790

Differential Revision: D6353840

Pulled By: hramos

fbshipit-source-id: 9712c459acc33092aae9909f3dd0b58a00b26afc
2017-11-16 17:04:45 -08:00
ashoat 833b27483b Fix Flow errors at declaration of most major library components
Summary:
The relevant changes in the PR are to Libraries/StyleSheet/EdgeInsetsPropType.js; the rest are just removals of FlowIgnores.

The definition of the relevant types is [here](https://github.com/facebook/flow/blob/master/lib/react.js#L262-L271).

The long and short of it is that for whatever reason, Flow is unable to realize that `ReactPropsChainableTypeChecker` is a subtype of `ReactPropsCheckType` unless we assert it. Once we explicitly hint this to the typechecker, it realizes that `EdgeInsetsPropType` is indeed a valid React PropType, and stops complaining that it isn't.
Closes https://github.com/facebook/react-native/pull/16437

Differential Revision: D6109742

Pulled By: sahrens

fbshipit-source-id: e4e10720b68c912d0372d810409f389b65d7f4b1
2017-10-20 03:50:25 -07:00
Seth Fitzsimmons 9afb71fde8 Replace React.createClass with create-react-class
Summary:
This replaces all uses of `React.createClass` with `createReactClass` from the `create-react-class` package, attempting to match use of `var` and `const` according to local style.

Fixes #14620
Refs #14712
Closes https://github.com/facebook/react-native/pull/14729

Differential Revision: D5321810

Pulled By: hramos

fbshipit-source-id: ae7b40640b2773fd89c3fb727ec87f688bebf585
2017-07-07 14:36:01 -07:00
Brian Vaughn 119959252e Remove RN fiber createClass wrapper around View
Reviewed By: spicyj

Differential Revision: D5241527

fbshipit-source-id: 9209004544e83cc0f03fcaa27c9b1acf8db09930
2017-06-21 12:38:06 -07:00
Matt Mahoney 05ec85043b Add Prop type for View
Reviewed By: yungsters

Differential Revision: D5098891

fbshipit-source-id: 5e1304344744e57c4d7f97455f49e1444fb7a42b
2017-05-23 08:01:48 -07:00
Brian Vaughn 6564edce5e Ran PropTypes -> prop-types codemod against Libraries/FBReactKit/js/react-native-github
Reviewed By: acdlite

Differential Revision: D4876709

fbshipit-source-id: 3a5e92bfc74287b7a9054546c438580bed0147af
2017-04-12 16:15:15 -07:00
Brian Vaughn 1129c6096d Replaced View.propTypes with a static getter that warned about deprecation
Reviewed By: spicyj

Differential Revision: D4766860

fbshipit-source-id: c0ef46df58b6167178e801d9dbe481101c0dc773
2017-03-28 11:32:09 -07:00
Brian Vaughn 53905a537a ReactNative moved View.propTypes to ViewPropTypes
Reviewed By: yungsters

Differential Revision: D4761354

fbshipit-source-id: b49922d78ee5d8628f945e5dee476ffe5d889b07
2017-03-23 09:15:42 -07:00
Brian Vaughn ef3db66bb1 Added deprecation warning for View.* static accessibility traits accessors
Reviewed By: spicyj

Differential Revision: D4749932

fbshipit-source-id: 5f07200e953f589f939196a161a1bc796c553868
2017-03-22 10:00:54 -07:00
Brian Vaughn 9344f3a95b Support string return type from RN createReactNativeFiberComponentClass()
Reviewed By: sebmarkbage

Differential Revision: D4607283

fbshipit-source-id: 466d2373dd570f77ebcced306d2f20a3f72d79c6
2017-03-20 13:07:06 -07:00
Jeff Morrison 59257d6976 fbobjc
Reviewed By: gabelevi

Differential Revision: D4652687

fbshipit-source-id: 6069c8bc24f0b88da3537ada877cdb7d1d4eccfd
2017-03-04 19:30:34 -08:00
Valentin Shergin b00c1fa3b6 `accessibilityViewIsModal` property was exposed for any view (iOS only)
Reviewed By: mmmulani

Differential Revision: D4582786

fbshipit-source-id: 0902b8cc762042e772798ea7eaa350bc9d737cfb
2017-02-27 23:46:14 -08:00
Pieter De Baets dba133a291 Merge AndroidConstants and IOSConstants into PlatformConstants
Reviewed By: AaaChiuuu

Differential Revision: D4597790

fbshipit-source-id: 0a54598d6e9cadb75efff4ac17c13899d6785f9b
2017-02-22 15:01:11 -08:00
Tim Yung 778cf289a8 RN: Export Accessibility Prop Types
Summary: Exports Flow types for the props related to accessibility.

Reviewed By: fkgozali

Differential Revision: D4498562

fbshipit-source-id: 2fb6e78d4ceaf9f26b6ea88d515b7b28f570de52
2017-02-02 23:28:31 -08:00
Paul Mestemaker 8378f0f9f7 Ensure documentation has consistent relative links
Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?

I had tried fixing a broken link in a previous commit (#11453). My commit was merged, but it did not resolve the underlying problem. I have looked into how links should be formed for the docs and have fixed the original problem as well as updated all other links to be consistent.

Previous link formats:

- /docs/sample.html <-- broken link
- sample.html <-- broken link
- https://facebook.github.io/react-native/docs/sample.html <-- works
- /react-native/docs/sample.html <-- works
- docs/sample.html <-- works (permalink format)

This PR updates all links to the permalink format.

**Test plan (required)**
I ran the website locally and manually tested half of the links in each category. They all worked.
```
$ cd website
$ npm install && npm start
```
Closes https://github.com/facebook/react-native/pull/12064

Differential Revision: D4489153

Pulled By: mkonicek

fbshipit-source-id: bf0231d941ba147317595c3b3466dc579a887169
2017-01-31 12:13:31 -08:00
David Aurelio 517abba6bb Require `fbjs/lib/invariant` instead of `invariant`
Summary: `'invariant'` can only be resolved by chance if node modules have been installed with npm3 or yarn, as it is a transitive dependency of `babel-traverse`. This changes the import to the direct dependency `fbjs/lib/invariant`.

Reviewed By: jeanlauliac, astreet

Differential Revision: D4462471

fbshipit-source-id: 5c841845012ed22a7c6264d46326a47807948513
2017-01-25 10:43:55 -08:00
Andy Street 963e6e9d36 Improve error messages when nesting View in Text
Summary: Since we don't support this, we should throw early. Also tries to improve the error message when adding a node that doesn't have a YogaNode to a node that can't measure itself.

Reviewed By: andreicoman11

Differential Revision: D4421542

fbshipit-source-id: e0be8cdd763091145e5e6af2db91515f4d236b37
2017-01-18 09:28:26 -08:00
Pieter De Baets c92ad5f6ae Apple TV support 4: support for input (tvOS focus engine)
Reviewed By: shergin

Differential Revision: D4333546

fbshipit-source-id: 8655070e81dbb62a80ab1f00a43ef6c2d9654618
2016-12-19 06:28:40 -08:00
David Aurelio 3683beb88a RN: Update React (2/2)
Reviewed By: kentaromiura

Differential Revision: D4026114

fbshipit-source-id: 67808af91454d95941fea01eef58a4d9086f46e1
2016-11-04 05:43:44 -07:00
Pieter De Baets 384ea330c8 Move Platform constants to RCTPlatform
Reviewed By: majak

Differential Revision: D4081849

fbshipit-source-id: bee08af2f68dcc1af424f382f960ff897ba11945
2016-10-27 04:29:00 -07:00
Tim Yung 7263c349c7 RN: Stop Deep Linking `ReactPropTypes`
Reviewed By: sebmarkbage

Differential Revision: D4025448

fbshipit-source-id: 4e9b6ee002a86f638fc57a4bbeb45bf35fabf74c
2016-10-14 18:59:10 -07:00
Felix Oghina 6d175f2c25 Android: enable foreground ripple
Reviewed By: astreet

Differential Revision: D3932066

fbshipit-source-id: ee2f019cb9ba41e32cbbd8c1cd07c9ed5263fddc
2016-10-03 04:28:46 -07:00
Jeff Morrison 1a9853da37 fbobjc
Reviewed By: gabelevi

Differential Revision: D3949455

fbshipit-source-id: 1cbce4a85fe5b8798496752863bbca64b078aa9c
2016-10-01 11:16:21 -07:00
Matej Matiasko 295ee16430 Fix View documentation typo
Summary:
Fix typo in View component documentation.
Closes https://github.com/facebook/react-native/pull/10097

Differential Revision: D3923619

Pulled By: davidaurelio

fbshipit-source-id: ebe63eec8ebdb36cfa7e3f501a214b9e11b17aef
2016-09-26 06:13:55 -07:00
Janic Duplessis d0d1712851 Reverted commit D3827366
Summary:
This adds support for sticky headers on Android. The implementation if based primarily on the iOS one (https://github.com/facebook/react-native/blob/master/React/Views/RCTScrollView.m#L272) and adds some stuff that was missing to be able to handle z-index, view clipping, view hierarchy optimization and touch handling properly.

Some notable changes:
- Add `ChildDrawingOrderDelegate` interface to allow changing the `ViewGroup` drawing order using `ViewGroup#getChildDrawingOrder`. This is used to change the content view drawing order to make sure headers are drawn over the other cells. Right now I'm only reversing the drawing order as drawing only the header views last added a lot of complexity especially because of view clipping and I don't think it should cause issues.

- Add `collapsableChildren` prop that works like `collapsable` but applies to every child of the view. This is needed to be able to reference sticky headers by their indices otherwise some subviews can get optimized out and break indexes.
Closes https://github.com/facebook/react-native/pull/9456

Differential Revision: D3827366

Pulled By: fred2028

fbshipit-source-id: d346068734c5b987518794ab23e13914ed13b5c4
2016-09-15 12:13:39 -07:00
Janic Duplessis 0e8b75b22c Implement ScrollView sticky headers on Android
Summary:
This adds support for sticky headers on Android. The implementation if based primarily on the iOS one (https://github.com/facebook/react-native/blob/master/React/Views/RCTScrollView.m#L272) and adds some stuff that was missing to be able to handle z-index, view clipping, view hierarchy optimization and touch handling properly.

Some notable changes:
- Add `ChildDrawingOrderDelegate` interface to allow changing the `ViewGroup` drawing order using `ViewGroup#getChildDrawingOrder`. This is used to change the content view drawing order to make sure headers are drawn over the other cells. Right now I'm only reversing the drawing order as drawing only the header views last added a lot of complexity especially because of view clipping and I don't think it should cause issues.

- Add `collapsableChildren` prop that works like `collapsable` but applies to every child of the view. This is needed to be able to reference sticky headers by their indices otherwise some subviews can get optimized out and break indexes.
Closes https://github.com/facebook/react-native/pull/9456

Differential Revision: D3827366

fbshipit-source-id: cab044cfdbe2ccb98e1ecd3e02ed3ceaa253eb78
2016-09-14 20:43:29 -07:00
origsun e8c8a06329 Fix bad link typo in View document
Summary:
This is trivial.

It fixes a bad link in http://facebook.github.io/react-native/docs/view.html#importantforaccessibility (the "Android importantForAccessibility docs" link).
Closes https://github.com/facebook/react-native/pull/9099

Differential Revision: D3647803

Pulled By: mkonicek

fbshipit-source-id: 8c75da03d926f60db0c75237b9ad48983bf9738f
2016-07-31 07:28:23 -07:00
David Aurelio bd60d828c5 Remove `node_modules/react` from the list of discoverable haste modules
Summary: This removes `node_modules/react` from the list of directories that are used for haste module resolutions. Modules required from React are now imported with `require('react/lib/…')`.

Reviewed By: astreet

Differential Revision: D3509863

fbshipit-source-id: 32cd34e2b8496f0a6676dbe6bb1eacc18124c01e
2016-07-05 06:44:33 -07:00
Joel Marcey 678ea5b233 Fix nits in update View API documentation
Summary:
Ref comments in #8341

Ref #8203
Closes https://github.com/facebook/react-native/pull/8361

Differential Revision: D3477174

Pulled By: caabernathy

fbshipit-source-id: 495011c2d370d06d355e966d6ba2c52880146183
2016-06-23 12:13:34 -07:00
Joel Marcey 9b9df78e28 Update Views API documentation
Summary:
Ensure all `props` have documentation. Add more details to current `props`.
Provide more information to the API in general.

> Would like to try to integrate the React Native Web Player for the initial
> example, but not right now.
Closes https://github.com/facebook/react-native/pull/8341

Differential Revision: D3475105

Pulled By: caabernathy

fbshipit-source-id: 00ad30b2359831740715517278bec1d0231e089d
2016-06-23 02:28:58 -07:00
Janic Duplessis 56c40baa06 Fix bad wording in pointer events doc
Summary:Fix bad wording in the docs change I did in #6534

cc mkonicek
Closes https://github.com/facebook/react-native/pull/6598

Differential Revision: D3085957

Pulled By: vjeux

fb-gh-sync-id: 2b45ac72acf089be6cf8e815aac430a2ce9d08ed
shipit-source-id: 2b45ac72acf089be6cf8e815aac430a2ce9d08ed
2016-03-24 19:53:26 -07:00
Janic Duplessis f1a0695c7d Improve pointerEvents doc
Summary:The docs for touchEvents was really unclear and assumed that you know what `pointer-events` does in CSS. This is confusing especially for native developers, see [this issue](http://stackoverflow.com/questions/36068392/set-userinteractionenabled-false-in-react-native/36096413) on stack overflow.

I added a short description to the prop and all the possible enum values and made it so the comment that explain why it is a prop and not a style doesn't appear on the website as it is not really relevant there.

**Test plan (required)**
Tested by running the website locally.
Closes https://github.com/facebook/react-native/pull/6534

Differential Revision: D3075198

Pulled By: mkonicek

fb-gh-sync-id: 57c8444fc83a31599dc872c361b142531cdd4885
shipit-source-id: 57c8444fc83a31599dc872c361b142531cdd4885
2016-03-20 18:02:18 -07:00
Jesse Ruder 0176ac488e Add hitSlop prop on iOS and Android
Summary:New prop `hitSlop` allows extending the touch area of Touchable components. This makes it easier to touch small buttons without needing to change your styles.

It takes `top`, `bottom`, `left`, and `right` same as the `pressRetentionOffset` prop. When a touch is moved, `hitSlop` is combined with `pressRetentionOffset` to determine how far the touch can move off the button before deactivating the button.

On Android I had to add a new file `ids.xml` to generate a unique ID to use for the tag where I store the `hitSlop` state. The iOS side is more straightforward.

terribleben worked on the iOS and JS parts of this diff.

Fixes #110
Closes https://github.com/facebook/react-native/pull/5720

Differential Revision: D2941671

Pulled By: androidtrunkagent

fb-gh-sync-id: 07e3eb8b6a36eebf76968fdaac3c6ac335603194
shipit-source-id: 07e3eb8b6a36eebf76968fdaac3c6ac335603194
2016-02-16 16:51:39 -08:00
trave7er 4237a27ec9 pick up some easy-to-fix lint warnings
Reviewed By: svcscm

Differential Revision: D2938097

fb-gh-sync-id: e3373bd44267251d8351d5203be1c88676aa8685
shipit-source-id: e3373bd44267251d8351d5203be1c88676aa8685
2016-02-16 02:00:57 -08:00
Nick Lockwood f685878938 Improved 3D touch implementation, and added example
Summary:
public
This diff improves the implementation of 3D touch by adding a `forceTouchAvailable` constant to View that can be used to check if the feature is supported.

I've also added an example of how you can use the `force` property of the touch event to measure touch pressure in React Native.

Reviewed By: vjeux

Differential Revision: D2864926

fb-gh-sync-id: 754c54989212ce4e4863716ceaba59673f0bb29d
2016-01-27 09:05:36 -08:00