Compare commits

...
Author SHA1 Message Date
Mike Grabowski 35de46278a [0.28.0] Bump version numbers 2016-06-21 21:01:43 +02:00
Satyajit SahooandMike Grabowski 6069fdd561 Show better error message when accessing React APIs on React Native
Summary:
**Motivation:**

Lots of examples on the web still have the old way to import React APIs from React Native. Also when someone upgrades to latest version of React Native without reading the release notes can get confused. This PR adds getters for  `createClass` and `Component` and throws an error with a better error message when they are accessed.

![screenshot_20160614-125622](https://cloud.githubusercontent.com/assets/1174278/16034600/47c70222-3230-11e6-9fe4-1a3493708829.png)

**Test plan:**

Trying to use `ReactNative.createClass` or `ReactNative.Component` will throw an error with this error message.

There's currently a bug in `symbolicateStackTrace` which actually crashes the app after showing the error due to the `stack` being null when updating the stack trace. But that's a separate issue which should be fixed separately. For now, to prevent the crash, we need to add the following before the return statement here - https://github.com/facebook/react-native/blob/master/Libraries/JavaScriptAppEn
Closes https://github.com/facebook/react-native/pull/8099

Differential Revision: D3430468

Pulled By: javache

fbshipit-source-id: c098e51e1f2c276d87eca6da3bd91a457d7840c5
2016-06-20 23:16:28 +02:00
Ahmed El-HelwandMike Grabowski ccd0181483 Don't close reference to image in getSize
Summary:
ImageLoader improperly closes both the image reference
(which is shared) and the DataSource (which is shared, and should only be
handled by BaseDataSubscriber when it is correct).

Reviewed By: plamenko

Differential Revision: D3441752

fbshipit-source-id: bfb3d0281cd9ae789cba4079978ef46d295ac8f5
2016-06-20 23:16:07 +02:00
Olivier NotteghemandMike Grabowski a7a34a14db Fix missing check causing layout some animation code to be executed when it shouldn't
Reviewed By: dmmiller

Differential Revision: D3404149

fbshipit-source-id: 8663325fd3a4b9257d84075e22bd9cc59d6414ac
2016-06-20 23:15:53 +02:00
Nicolas CharpentierandMike Grabowski 3716ce741a Add Fresco to ProGuard
Summary:
Motivation #7760
Closes https://github.com/facebook/react-native/pull/7781

Differential Revision: D3397772

fbshipit-source-id: 02b6fd4a403da590fd1c55c554eca00e15899a03
2016-06-20 23:15:23 +02:00
Nicolas CharpentierandMike Grabowski 22c7ef9d99 Add Fresco to ProGuard
Summary:
Motivation #7760
Closes https://github.com/facebook/react-native/pull/7781

Differential Revision: D3397772

fbshipit-source-id: 02b6fd4a403da590fd1c55c554eca00e15899a03
2016-06-20 23:14:43 +02:00
SreejumonandMike Grabowski 6c3306d0c8 Fix the WebSocket sendBinary error
Summary:
Fixing the WebSocket SendBinary method error. This is a regression caused during recent change.
Closes https://github.com/facebook/react-native/pull/7956

Differential Revision: D3398065

fbshipit-source-id: 5d56eba807b59d1f3265cba5d5f501d610afebf2
2016-06-20 23:14:23 +02:00
Mike Grabowski faa67dbfeb [0.28.0-rc.0] Bump version numbers 2016-06-06 10:13:31 +02:00
9 changed files with 61 additions and 18 deletions
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule throwOnWrongReactAPI
* @flow
*/
'use strict';
function throwOnWrongReactAPI(key: string) {
throw new Error(
`Seems you're trying to access 'ReactNative.${key}' from the 'react-native' package. Perhaps you meant to access 'React.${key}' from the 'react' package instead?
For example, instead of:
import React, { Component, View } from 'react-native';
You should now do:
import React, { Component } from 'react';
import { View } from 'react-native';
Check the release notes on how to upgrade your code - https://github.com/facebook/react-native/releases/tag/v0.25.1
`);
}
module.exports = throwOnWrongReactAPI;
+14
View File
@@ -173,6 +173,20 @@ const ReactNative = {
},
};
// Better error messages when accessing React APIs on ReactNative
if (__DEV__) {
const throwOnWrongReactAPI = require('throwOnWrongReactAPI');
const reactAPIs = [ 'createClass', 'Component' ];
for (const key of reactAPIs) {
Object.defineProperty(ReactNative, key, {
get() { throwOnWrongReactAPI(key); },
enumerable: false,
configurable: false
});
}
}
// Preserve getters with warnings on the internal ReactNative copy without
// invoking them.
const ReactNativeInternal = require('ReactNative');
+1 -1
View File
@@ -4,7 +4,7 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = "React"
s.version = package['version']
s.version = "0.28.0"
s.summary = package['description']
s.description = <<-DESC
React Native apps are built using the React JS
+1 -1
View File
@@ -1,4 +1,4 @@
VERSION_NAME=1000.0.0-master
VERSION_NAME=0.28.0
GROUP=com.facebook.react
POM_NAME=ReactNative
@@ -11,9 +11,6 @@ package com.facebook.react.modules.image;
import android.net.Uri;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.WritableMap;
import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.references.CloseableReference;
import com.facebook.datasource.BaseDataSubscriber;
@@ -23,10 +20,12 @@ import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.image.CloseableImage;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
public class ImageLoaderModule extends ReactContextBaseJavaModule {
@@ -83,27 +82,20 @@ public class ImageLoaderModule extends ReactContextBaseJavaModule {
sizes.putInt("width", image.getWidth());
sizes.putInt("height", image.getHeight());
image.close();
promise.resolve(sizes);
} catch (Exception e) {
promise.reject(ERROR_GET_SIZE_FAILURE, e);
} finally {
CloseableReference.closeSafely(ref);
dataSource.close();
}
} else {
dataSource.close();
promise.reject(ERROR_GET_SIZE_FAILURE);
}
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
try {
promise.reject(ERROR_GET_SIZE_FAILURE, dataSource.getFailureCause());
} finally {
dataSource.close();
}
promise.reject(ERROR_GET_SIZE_FAILURE, dataSource.getFailureCause());
}
};
dataSource.subscribe(dataSubscriber, CallerThreadExecutor.getInstance());
@@ -223,7 +223,7 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
throw new RuntimeException("Cannot send a message. Unknown WebSocket id " + id);
}
try {
client.sendMessage(RequestBody.create(WebSocket.TEXT, ByteString.decodeBase64(base64String)));
client.sendMessage(RequestBody.create(WebSocket.BINARY, ByteString.decodeBase64(base64String)));
} catch (IOException | IllegalStateException e) {
notifyWebSocketFailed(id, e.getMessage());
}
@@ -348,7 +348,8 @@ public class NativeViewHierarchyManager {
View viewToRemove = viewToManage.getChildAt(indexToRemove);
if (mLayoutAnimator.shouldAnimateLayout(viewToRemove) &&
if (mLayoutAnimationEnabled &&
mLayoutAnimator.shouldAnimateLayout(viewToRemove) &&
arrayContains(tagsToDelete, viewToRemove.getId())) {
// The view will be removed and dropped by the 'delete' layout animation
// instead, so do nothing
@@ -395,7 +396,8 @@ public class NativeViewHierarchyManager {
tagsToDelete));
}
if (mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) {
if (mLayoutAnimationEnabled &&
mLayoutAnimator.shouldAnimateLayout(viewToDestroy)) {
mLayoutAnimator.deleteView(viewToDestroy, new LayoutAnimationListener() {
@Override
public void onAnimationEnd() {
@@ -26,11 +26,14 @@
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.proguard.annotations.DoNotStrip *;
@com.facebook.common.internal.DoNotStrip *;
}
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "react-native",
"version": "1000.0.0",
"version": "0.28.0",
"description": "A framework for building native apps using React",
"license": "BSD-3-Clause",
"repository": {
@@ -204,4 +204,4 @@
"react": "^15.1.0",
"shelljs": "0.6.0"
}
}
}