Compare commits

...
9 Commits
Author SHA1 Message Date
Mike Grabowski 2e384184bc [0.55.0] Bump version numbers 2018-04-03 16:58:34 +02:00
Danny CochranandMike Grabowski 3d69b5ce5c Pass invertStickyHeaders to ScrollView
Summary:
invertStickyHeaders was being set to "this.props.inverted" -- it should just inherit from the props of VirtualizedList instead, per discussion in https://github.com/facebook/react-native/issues/18471

Fixes #18471

Pass "invertStickyHeaders: false" to a SectionList (or FlatList), and expect that your sticky headers stick to the bottom of the ScrollView, instead of the top.

none

[ANDROID] [BUGFIX] [SectionList] - invertStickyHeaders can now be set from SectionList or FlatList.
Closes https://github.com/facebook/react-native/pull/18524

Differential Revision: D7386163

Pulled By: hramos

fbshipit-source-id: 3b66dfca280e657303f69f98c5a8bc0df033f9f7
2018-04-03 16:57:52 +02:00
Mike Grabowski c70578ab76 [0.55.0-rc.2] Bump version numbers 2018-03-28 19:12:20 +02:00
Janic DuplessisandMike Grabowski 093a78d99d Fix blob response parsing for empty body on iOS
Summary:
We currently handle empty body poorly in the iOS blob implementation, this happens because of an early return that cause the blob response to not be processed by the blob module, resulting in an empty string as the body instead of a blob object. We also need to make sure to create an empty blob object when data is nil (empty body) as per the XMLHttpRequest spec. The Android implementation was already handling this properly.

Fixes #18223

Send a HEAD request

```js
fetch('https://apipre.monkimun.com/whoami', {
  body: null,
  method: 'HEAD',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
})
```

[IOS][BUGFIX][Blob] - Fix blob response parsing for empty body
Closes https://github.com/facebook/react-native/pull/18547

Differential Revision: D7415950

Pulled By: hramos

fbshipit-source-id: 56860532c6171255869f02a0960f55d155184a46
2018-03-28 19:12:09 +02:00
Eric SamelsonandMike Grabowski 8a6ab14200 fix ReadableNativeMap.toHashMap() for nested maps and arrays
Summary:
<!--
  Required: Write your motivation here.
  If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->

Commit https://github.com/facebook/react-native/commit/7891805d22e3fdc821961ff0ccc5c450c3d625c8 broke the previous behavior of `ReadableNativeMap.toHashMap()` for nested maps and arrays. Previously, all nested `ReadableNativeMap`s and `ReadableNativeArray`s were recursively converted to `HashMap`s and `ArrayList`s, but this is lost when only `getLocalMap()` is returned.

<!--
  Required: 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!
-->

Call `ReadableNativeMap.toHashMap()` on a map with values of type `ReadableNativeMap` and `ReadableNativeArray`. Verify the returned hash map has these converted to `HashMap` and `ArrayList`, respectively.

<!--
  Does this PR require a documentation change?
  Create a PR at https://github.com/facebook/react-native-website and add a link to it here.
-->

<!--
  Required.
  Help reviewers and the release process by writing your own release notes. See below for an example.
-->

[ANDROID] [BUGFIX] [ReadableNativeMap] - Fix toHashMap() for nested maps and arrays

<!--
  **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

    CATEGORY
  [----------]      TYPE
  [ CLI      ] [-------------]    LOCATION
  [ DOCS     ] [ BREAKING    ] [-------------]
  [ GENERAL  ] [ BUGFIX      ] [ {Component} ]
  [ INTERNAL ] [ ENHANCEMENT ] [ {Filename}  ]
  [ IOS      ] [ FEATURE     ] [ {Directory} ]   |-----------|
  [ ANDROID  ] [ MINOR       ] [ {Framework} ] - | {Message} |
  [----------] [-------------] [-------------]   |-----------|

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/18455

Reviewed By: kathryngray

Differential Revision: D7347344

Pulled By: mdvacca

fbshipit-source-id: af2bca9dec6c0cb8a7da099b6757434fcc3ac785
2018-03-28 19:12:05 +02:00
Mike Grabowski b20827250e [0.55.0-rc.1] Bump version numbers 2018-03-20 21:50:22 +01:00
Mike Grabowski ca8ce83cc3 Fix issues with pollParams and link 2018-03-20 21:43:47 +01:00
Héctor RamosandMike Grabowski 85b690fb22 React sync for revisions ab4280b...ad9544f
Reviewed By: bvaughn

Differential Revision: D7256390

fbshipit-source-id: 9fe1324da93cb8f4a7f478e1037944774b9b95ff
2018-03-20 21:39:49 +01:00
Mike Grabowski 9c29faf6a9 [0.55.0-rc.0] Bump version numbers 2018-03-12 23:53:13 +01:00
18 changed files with 487 additions and 310 deletions
+3
View File
@@ -258,6 +258,9 @@ RCT_EXPORT_METHOD(release:(NSString *)blobId)
- (id)handleNetworkingResponse:(NSURLResponse *)response data:(NSData *)data
{
// An empty body will have nil for data, in this case we need to return
// an empty blob as per the XMLHttpRequest spec.
data = data ?: [NSData new];
return @{
@"blobId": [self store:data],
@"offset": @0,
+1 -1
View File
@@ -12,7 +12,7 @@
exports.version = {
major: 0,
minor: 0,
minor: 55,
patch: 0,
prerelease: null,
};
+3 -1
View File
@@ -899,7 +899,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
onScrollEndDrag: this._onScrollEndDrag,
onMomentumScrollEnd: this._onMomentumScrollEnd,
scrollEventThrottle: this.props.scrollEventThrottle, // TODO: Android support
invertStickyHeaders: this.props.inverted,
invertStickyHeaders: this.props.invertStickyHeaders !== undefined
? this.props.invertStickyHeaders
: this.props.inverted,
stickyHeaderIndices,
};
if (inversionStyle) {
+4 -4
View File
@@ -439,10 +439,6 @@ RCT_EXPORT_MODULE()
{
RCTAssertThread(_methodQueue, @"sendData: must be called on method queue");
if (data.length == 0) {
return;
}
id responseData = nil;
for (id<RCTNetworkingResponseHandler> handler in _responseHandlers) {
if ([handler canHandleNetworkingResponse:responseType]) {
@@ -452,6 +448,10 @@ RCT_EXPORT_MODULE()
}
if (!responseData) {
if (data.length == 0) {
return;
}
if ([responseType isEqualToString:@"text"]) {
// No carry storage is required here because the entire data has been loaded.
responseData = [RCTNetworking decodeTextData:data fromResponse:task.response withCarryData:nil];
+1 -1
View File
@@ -1 +1 @@
ab4280b3e98dbb97d3e753083dab19879167c3f5
ad9544f48e58f2599a8ea0de1e9f4dd104db30bb
+96 -59
View File
@@ -3622,6 +3622,11 @@ var ReactNativeComponent = (function(_React$Component) {
/**
* Removes focus. This is the opposite of `focus()`.
*/
/**
* Due to bugs in Flow's handling of React.createClass, some fields already
* declared in the base class need to be redeclared below.
*/
ReactNativeComponent.prototype.blur = function blur() {
TextInputState.blurTextInput(findNumericNodeHandleFiber(this));
};
@@ -8327,11 +8332,11 @@ var rendererSigil = void 0;
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
{
warning(
@@ -8358,16 +8363,16 @@ function popProvider(providerFiber) {
stack[index$1] = null;
index$1 -= 1;
var context = providerFiber.type.context;
context.currentValue = currentValue;
context.changedBits = changedBits;
context._currentValue = currentValue;
context._changedBits = changedBits;
}
function resetProviderStack() {
for (var i = index$1; i > -1; i--) {
var providerFiber = stack[i];
var context = providerFiber.type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;
@@ -9149,48 +9154,70 @@ var ReactFiberBeginWork = function(
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
var changedBits = void 0;
if (oldProps === null) {
// Initial render
changedBits = MAX_SIGNED_31_BIT_INT;
} else {
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change.
if (oldProps.value === newProps.value) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context.calculateChangedBits === "function"
? context.calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context._calculateChangedBits === "function"
? context._calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
if (changedBits !== 0) {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
if (changedBits === 0) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
} else {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
}
}
}
}
@@ -9198,9 +9225,6 @@ var ReactFiberBeginWork = function(
workInProgress.stateNode = changedBits;
pushProvider(workInProgress);
if (oldProps !== null && oldProps.children === newProps.children) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
var newChildren = newProps.children;
reconcileChildren(current, workInProgress, newChildren);
return workInProgress.child;
@@ -9213,11 +9237,28 @@ var ReactFiberBeginWork = function(
) {
var context = workInProgress.type;
var newProps = workInProgress.pendingProps;
var oldProps = workInProgress.memoizedProps;
var newValue = context.currentValue;
var changedBits = context.changedBits;
var newValue = context._currentValue;
var changedBits = context._changedBits;
if (changedBits !== 0) {
if (hasContextChanged()) {
// Normally we can bail out on props equality but if context has changed
// we don't do the bailout and we have to reuse existing props instead.
} else if (changedBits === 0 && oldProps === newProps) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var observedBits = newProps.unstable_observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
// Store the observedBits on the fiber's stateNode for quick access.
workInProgress.stateNode = observedBits;
if ((changedBits & observedBits) !== 0) {
// Context change propagation stops at matching consumers, for time-
// slicing. Continue the propagation here.
propagateContextChange(
@@ -9226,24 +9267,20 @@ var ReactFiberBeginWork = function(
changedBits,
renderExpirationTime
);
} else if (oldProps !== null && oldProps.children === newProps.children) {
// No change. Bailout early if children are the same.
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
// Store the observedBits on the fiber's stateNode for quick access.
var observedBits = newProps.observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
workInProgress.stateNode = observedBits;
var render = newProps.children;
if (typeof render !== "function") {
invariant(
false,
"A context consumer was rendered with multiple children, or a child that isn't a function. " +
"A context consumer expects a single child that is a function. " +
"If you did pass a function, make sure there is no trailing or leading whitespace around it."
{
warning(
typeof render === "function",
"A context consumer was rendered with multiple children, or a child " +
"that isn't a function. A context consumer expects a single child " +
"that is a function. If you did pass a function, make sure there " +
"is no trailing or leading whitespace around it."
);
}
+117 -72
View File
@@ -3122,11 +3122,11 @@ var reconcileChildFibers = ChildReconciler(!0),
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
}
function popProvider(providerFiber) {
var changedBits = changedBitsStack[index$1],
@@ -3136,8 +3136,8 @@ function popProvider(providerFiber) {
stack[index$1] = null;
--index$1;
providerFiber = providerFiber.type.context;
providerFiber.currentValue = currentValue;
providerFiber.changedBits = changedBits;
providerFiber._currentValue = currentValue;
providerFiber._changedBits = changedBits;
}
function ReactFiberBeginWork(
config,
@@ -3289,6 +3289,72 @@ function ReactFiberBeginWork(
fiber = nextFiber;
}
}
function updateContextProvider(
current,
workInProgress,
renderExpirationTime
) {
var context = workInProgress.type.context,
newProps = workInProgress.pendingProps,
oldProps = workInProgress.memoizedProps;
if (!didPerformWorkStackCursor.current && oldProps === newProps)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
if (null === oldProps) newValue = 1073741823;
else if (oldProps.value === newProps.value) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else {
var oldValue = oldProps.value;
if (
(oldValue === newValue &&
(0 !== oldValue || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else if (
((newValue =
"function" === typeof context._calculateChangedBits
? context._calculateChangedBits(oldValue, newValue)
: 1073741823),
(newValue |= 0),
0 === newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
} else
propagateContextChange(
workInProgress,
context,
newValue,
renderExpirationTime
);
}
workInProgress.stateNode = newValue;
pushProvider(workInProgress);
reconcileChildren(current, workInProgress, newProps.children);
return workInProgress.child;
}
function bailoutOnAlreadyFinishedWork(current, workInProgress) {
invariant(
null === current || workInProgress.child === current.child,
@@ -3641,71 +3707,50 @@ function ReactFiberBeginWork(
current
);
case 13:
props = workInProgress.type.context;
fn = workInProgress.pendingProps;
unmaskedContext = workInProgress.memoizedProps;
if (didPerformWorkStackCursor.current || unmaskedContext !== fn) {
workInProgress.memoizedProps = fn;
updateQueue = fn.value;
if (null === unmaskedContext) updateQueue = 1073741823;
else {
var oldValue = unmaskedContext.value;
(oldValue === updateQueue &&
(0 !== oldValue || 1 / oldValue === 1 / updateQueue)) ||
(oldValue !== oldValue && updateQueue !== updateQueue)
? (updateQueue = 0)
: ((updateQueue =
"function" === typeof props.calculateChangedBits
? props.calculateChangedBits(oldValue, updateQueue)
: 1073741823),
(updateQueue |= 0),
0 !== updateQueue &&
propagateContextChange(
workInProgress,
props,
updateQueue,
renderExpirationTime
));
}
workInProgress.stateNode = updateQueue;
pushProvider(workInProgress);
null !== unmaskedContext && unmaskedContext.children === fn.children
? (current = bailoutOnAlreadyFinishedWork(
current,
workInProgress
))
: (reconcileChildren(current, workInProgress, fn.children),
(current = workInProgress.child));
} else
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
(current = bailoutOnAlreadyFinishedWork(current, workInProgress));
return current;
return updateContextProvider(
current,
workInProgress,
renderExpirationTime
);
case 12:
unmaskedContext = workInProgress.type;
fn = workInProgress.pendingProps;
props = unmaskedContext.currentValue;
updateQueue = unmaskedContext.changedBits;
0 !== updateQueue &&
propagateContextChange(
workInProgress,
unmaskedContext,
updateQueue,
renderExpirationTime
);
renderExpirationTime = fn.observedBits;
if (void 0 === renderExpirationTime || null === renderExpirationTime)
renderExpirationTime = 1073741823;
workInProgress.stateNode = renderExpirationTime;
renderExpirationTime = fn.children;
"function" !== typeof renderExpirationTime &&
invariant(
!1,
"A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."
);
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
return workInProgress.child;
a: {
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
updateQueue = workInProgress.memoizedProps;
props = fn._currentValue;
var changedBits = fn._changedBits;
if (
didPerformWorkStackCursor.current ||
0 !== changedBits ||
updateQueue !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
var observedBits = unmaskedContext.unstable_observedBits;
if (void 0 === observedBits || null === observedBits)
observedBits = 1073741823;
workInProgress.stateNode = observedBits;
if (0 !== (changedBits & observedBits))
propagateContextChange(
workInProgress,
fn,
changedBits,
renderExpirationTime
);
else if (
null !== updateQueue &&
updateQueue.children === unmaskedContext.children
) {
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
break a;
}
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
}
return current;
default:
invariant(
!1,
@@ -4581,8 +4626,8 @@ function ReactFiberScheduler(config) {
resetHostContainer();
for (var i = index$1; -1 < i; i--) {
var context = stack[i].type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;
+96 -59
View File
@@ -3968,6 +3968,11 @@ var ReactNativeComponent = (function(_React$Component) {
/**
* Removes focus. This is the opposite of `focus()`.
*/
/**
* Due to bugs in Flow's handling of React.createClass, some fields already
* declared in the base class need to be redeclared below.
*/
ReactNativeComponent.prototype.blur = function blur() {
TextInputState.blurTextInput(findNumericNodeHandleFiber(this));
};
@@ -8585,11 +8590,11 @@ var rendererSigil = void 0;
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
{
warning(
@@ -8616,16 +8621,16 @@ function popProvider(providerFiber) {
stack[index$1] = null;
index$1 -= 1;
var context = providerFiber.type.context;
context.currentValue = currentValue;
context.changedBits = changedBits;
context._currentValue = currentValue;
context._changedBits = changedBits;
}
function resetProviderStack() {
for (var i = index$1; i > -1; i--) {
var providerFiber = stack[i];
var context = providerFiber.type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;
@@ -9407,48 +9412,70 @@ var ReactFiberBeginWork = function(
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
var changedBits = void 0;
if (oldProps === null) {
// Initial render
changedBits = MAX_SIGNED_31_BIT_INT;
} else {
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change.
if (oldProps.value === newProps.value) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context.calculateChangedBits === "function"
? context.calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context._calculateChangedBits === "function"
? context._calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
if (changedBits !== 0) {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
if (changedBits === 0) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
} else {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
}
}
}
}
@@ -9456,9 +9483,6 @@ var ReactFiberBeginWork = function(
workInProgress.stateNode = changedBits;
pushProvider(workInProgress);
if (oldProps !== null && oldProps.children === newProps.children) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
var newChildren = newProps.children;
reconcileChildren(current, workInProgress, newChildren);
return workInProgress.child;
@@ -9471,11 +9495,28 @@ var ReactFiberBeginWork = function(
) {
var context = workInProgress.type;
var newProps = workInProgress.pendingProps;
var oldProps = workInProgress.memoizedProps;
var newValue = context.currentValue;
var changedBits = context.changedBits;
var newValue = context._currentValue;
var changedBits = context._changedBits;
if (changedBits !== 0) {
if (hasContextChanged()) {
// Normally we can bail out on props equality but if context has changed
// we don't do the bailout and we have to reuse existing props instead.
} else if (changedBits === 0 && oldProps === newProps) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var observedBits = newProps.unstable_observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
// Store the observedBits on the fiber's stateNode for quick access.
workInProgress.stateNode = observedBits;
if ((changedBits & observedBits) !== 0) {
// Context change propagation stops at matching consumers, for time-
// slicing. Continue the propagation here.
propagateContextChange(
@@ -9484,24 +9525,20 @@ var ReactFiberBeginWork = function(
changedBits,
renderExpirationTime
);
} else if (oldProps !== null && oldProps.children === newProps.children) {
// No change. Bailout early if children are the same.
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
// Store the observedBits on the fiber's stateNode for quick access.
var observedBits = newProps.observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
workInProgress.stateNode = observedBits;
var render = newProps.children;
if (typeof render !== "function") {
invariant(
false,
"A context consumer was rendered with multiple children, or a child that isn't a function. " +
"A context consumer expects a single child that is a function. " +
"If you did pass a function, make sure there is no trailing or leading whitespace around it."
{
warning(
typeof render === "function",
"A context consumer was rendered with multiple children, or a child " +
"that isn't a function. A context consumer expects a single child " +
"that is a function. If you did pass a function, make sure there " +
"is no trailing or leading whitespace around it."
);
}
+117 -72
View File
@@ -3376,11 +3376,11 @@ var reconcileChildFibers = ChildReconciler(!0),
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
}
function popProvider(providerFiber) {
var changedBits = changedBitsStack[index$1],
@@ -3390,8 +3390,8 @@ function popProvider(providerFiber) {
stack[index$1] = null;
--index$1;
providerFiber = providerFiber.type.context;
providerFiber.currentValue = currentValue;
providerFiber.changedBits = changedBits;
providerFiber._currentValue = currentValue;
providerFiber._changedBits = changedBits;
}
function ReactFiberBeginWork(
config,
@@ -3552,6 +3552,72 @@ function ReactFiberBeginWork(
fiber = nextFiber;
}
}
function updateContextProvider(
current,
workInProgress,
renderExpirationTime
) {
var context = workInProgress.type.context,
newProps = workInProgress.pendingProps,
oldProps = workInProgress.memoizedProps;
if (!didPerformWorkStackCursor.current && oldProps === newProps)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
if (null === oldProps) newValue = 1073741823;
else if (oldProps.value === newProps.value) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else {
var oldValue = oldProps.value;
if (
(oldValue === newValue &&
(0 !== oldValue || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else if (
((newValue =
"function" === typeof context._calculateChangedBits
? context._calculateChangedBits(oldValue, newValue)
: 1073741823),
(newValue |= 0),
0 === newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
} else
propagateContextChange(
workInProgress,
context,
newValue,
renderExpirationTime
);
}
workInProgress.stateNode = newValue;
pushProvider(workInProgress);
reconcileChildren(current, workInProgress, newProps.children);
return workInProgress.child;
}
function bailoutOnAlreadyFinishedWork(current, workInProgress) {
invariant(
null === current || workInProgress.child === current.child,
@@ -3904,71 +3970,50 @@ function ReactFiberBeginWork(
current
);
case 13:
props = workInProgress.type.context;
fn = workInProgress.pendingProps;
unmaskedContext = workInProgress.memoizedProps;
if (didPerformWorkStackCursor.current || unmaskedContext !== fn) {
workInProgress.memoizedProps = fn;
updateQueue = fn.value;
if (null === unmaskedContext) updateQueue = 1073741823;
else {
var oldValue = unmaskedContext.value;
(oldValue === updateQueue &&
(0 !== oldValue || 1 / oldValue === 1 / updateQueue)) ||
(oldValue !== oldValue && updateQueue !== updateQueue)
? (updateQueue = 0)
: ((updateQueue =
"function" === typeof props.calculateChangedBits
? props.calculateChangedBits(oldValue, updateQueue)
: 1073741823),
(updateQueue |= 0),
0 !== updateQueue &&
propagateContextChange(
workInProgress,
props,
updateQueue,
renderExpirationTime
));
}
workInProgress.stateNode = updateQueue;
pushProvider(workInProgress);
null !== unmaskedContext && unmaskedContext.children === fn.children
? (current = bailoutOnAlreadyFinishedWork(
current,
workInProgress
))
: (reconcileChildren(current, workInProgress, fn.children),
(current = workInProgress.child));
} else
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
(current = bailoutOnAlreadyFinishedWork(current, workInProgress));
return current;
return updateContextProvider(
current,
workInProgress,
renderExpirationTime
);
case 12:
unmaskedContext = workInProgress.type;
fn = workInProgress.pendingProps;
props = unmaskedContext.currentValue;
updateQueue = unmaskedContext.changedBits;
0 !== updateQueue &&
propagateContextChange(
workInProgress,
unmaskedContext,
updateQueue,
renderExpirationTime
);
renderExpirationTime = fn.observedBits;
if (void 0 === renderExpirationTime || null === renderExpirationTime)
renderExpirationTime = 1073741823;
workInProgress.stateNode = renderExpirationTime;
renderExpirationTime = fn.children;
"function" !== typeof renderExpirationTime &&
invariant(
!1,
"A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."
);
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
return workInProgress.child;
a: {
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
updateQueue = workInProgress.memoizedProps;
props = fn._currentValue;
var changedBits = fn._changedBits;
if (
didPerformWorkStackCursor.current ||
0 !== changedBits ||
updateQueue !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
var observedBits = unmaskedContext.unstable_observedBits;
if (void 0 === observedBits || null === observedBits)
observedBits = 1073741823;
workInProgress.stateNode = observedBits;
if (0 !== (changedBits & observedBits))
propagateContextChange(
workInProgress,
fn,
changedBits,
renderExpirationTime
);
else if (
null !== updateQueue &&
updateQueue.children === unmaskedContext.children
) {
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
break a;
}
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
}
return current;
default:
invariant(
!1,
@@ -4977,8 +5022,8 @@ function ReactFiberScheduler(config) {
resetHostContainer();
for (var i = index$1; -1 < i; i--) {
var context = stack[i].type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;
-4
View File
@@ -9,8 +9,6 @@
*/
'use strict';
const BatchedBridge = require('BatchedBridge');
// TODO @sema: Adjust types
import type {ReactNativeType} from 'ReactNativeTypes';
@@ -22,6 +20,4 @@ if (__DEV__) {
ReactFabric = require('ReactFabric-prod');
}
BatchedBridge.registerCallableModule('ReactFabric', ReactFabric);
module.exports = (ReactFabric: ReactNativeType);
+1 -16
View File
@@ -86,27 +86,12 @@ type SecretInternalsType = {
// And how much information to fill in for the above types.
};
declare class ReactNativeComponent<Props, State = void>
extends React$Component<Props, State> {
blur(): void,
focus(): void,
measure(callback: MeasureOnSuccessCallback): void,
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void,
measureLayout(
relativeToNativeNode: number,
onSuccess: MeasureLayoutOnSuccessCallback,
onFail: () => void,
): void,
setNativeProps(nativeProps: Object): void,
}
/**
* Flat ReactNative renderer bundles are too big for Flow to parse efficiently.
* Provide minimal Flow typing for the high-level RN API and call it a day.
*/
export type ReactNativeType = {
NativeComponent: typeof ReactNativeComponent,
NativeComponent: any,
findNodeHandle(componentOrHandle: any): ?number,
render(
element: React$Element<any>,
+6 -4
View File
@@ -80,10 +80,12 @@ export type ReactContext<T> = {
$$typeof: Symbol | number,
Consumer: ReactContext<T>,
Provider: ReactProviderType<T>,
calculateChangedBits: ((a: T, b: T) => number) | null,
defaultValue: T,
currentValue: T,
changedBits: number,
_calculateChangedBits: ((a: T, b: T) => number) | null,
_defaultValue: T,
_currentValue: T,
_changedBits: number,
// DEV only
_currentRenderer?: Object | null,
+1 -1
View File
@@ -21,7 +21,7 @@ static void __makeVersion()
{
__rnVersion = @{
RCTVersionMajor: @(0),
RCTVersionMinor: @(0),
RCTVersionMinor: @(55),
RCTVersionPatch: @(0),
RCTVersionPrerelease: [NSNull null],
};
+1 -1
View File
@@ -1,4 +1,4 @@
VERSION_NAME=1000.0.0-master
VERSION_NAME=0.55.0
GROUP=com.facebook.react
POM_NAME=ReactNative
@@ -11,6 +11,7 @@ import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import java.util.HashMap;
import java.util.Iterator;
import com.facebook.infer.annotation.Assertions;
import javax.annotation.Nullable;
@@ -248,7 +249,31 @@ public class ReadableNativeMap extends NativeMap implements ReadableMap {
}
return hashMap;
}
return getLocalMap();
// we can almost just return getLocalMap(), but we need to convert nested arrays and maps to the
// correct types first
HashMap<String, Object> hashMap = new HashMap<>(getLocalMap());
Iterator iterator = hashMap.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
switch (getType(key)) {
case Null:
case Boolean:
case Number:
case String:
break;
case Map:
hashMap.put(key, Assertions.assertNotNull(getMap(key)).toHashMap());
break;
case Array:
hashMap.put(key, Assertions.assertNotNull(getArray(key)).toArrayList());
break;
default:
throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
}
}
return hashMap;
}
/**
@@ -16,7 +16,7 @@ import java.util.Map;
public class ReactNativeVersion {
public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
"major", 0,
"minor", 0,
"minor", 55,
"patch", 0,
"prerelease", null);
}
+11 -11
View File
@@ -37,7 +37,9 @@ log.heading = 'rnpm-link';
const dedupeAssets = (assets) => uniqBy(assets, asset => path.basename(asset));
const linkDependency = (platforms, project, dependency) => {
const linkDependency = async (platforms, project, dependency) => {
const params = await pollParams(dependency.config.params);
Object.keys(platforms || {})
.forEach(platform => {
if (!project[platform] || !dependency.config[platform]) {
@@ -56,18 +58,16 @@ const linkDependency = (platforms, project, dependency) => {
return null;
}
return pollParams(dependency.config.params).then(params => {
log.info(`Linking ${dependency.name} ${platform} dependency`);
log.info(`Linking ${dependency.name} ${platform} dependency`);
linkConfig.register(
dependency.name,
dependency.config[platform],
params,
project[platform]
);
linkConfig.register(
dependency.name,
dependency.config[platform],
params,
project[platform]
);
log.info(`Platform '${platform}' module ${dependency.name} has been successfully linked`);
});
log.info(`Platform '${platform}' module ${dependency.name} has been successfully linked`);
});
};
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "react-native",
"version": "1000.0.0",
"version": "0.55.0",
"description": "A framework for building native apps using React",
"license": "MIT",
"repository": {
@@ -224,4 +224,4 @@
"shelljs": "^0.7.8",
"sinon": "^2.2.0"
}
}
}