How can I force a component to re-render with hooks in React?

This is possible with useState or useReducer, since useState uses useReducer internally: const [, updateState] = React.useState(); const forceUpdate = React.useCallback(() => updateState({}), []); forceUpdate isn’t intended to be used under normal circumstances, only in testing or other outstanding cases. This situation may be addressed in a more conventional way. setCount is an example of … Read more

React-Native: Application has not been registered error

I guess it is an error caused by not matching name of project and your registered component. You have inited project with one name, i.e. react-native init AwesomeApp But in your index.ios.js file you register other component AppRegistry.registerComponent(‘Bananas’, () => Bananas); When it must be AppRegistry.registerComponent(‘AwesomeApp’, () => Bananas); If your component name does match, … Read more

Android failed to load JS bundle

To bundle JS file into your apk while having your server running (react-native start) download bundle into assets directory of your app: curl “http://localhost:8081/index.android.bundle?platform=android” -o “android/app/src/main/assets/index.android.bundle” With the next release (0.12) we’ll fix react-native bundle command to work with android projects as expected.

error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start of app

A possible solution for this is that you most probably not bundling your application first, perform the following steps and then deploy your app-debug.apk to your device $ cd myproject $ react-native start > /dev/null 2>&1 & $ curl “http://localhost:8081/index.android.bundle?platform=android” -o “android/app/src/main/assets/index.android.bundle” (if the folder assets does not exists create it) Then run from project … Read more

Build and Install unsigned apk on device without the development server?

You need to manually create the bundle for a debug build. Bundle debug build: #React-Native 0.59 react-native bundle –dev false –platform android –entry-file index.js –bundle-output ./android/app/src/main/assets/index.android.bundle –assets-dest ./android/app/src/main/res #React-Native 0.49.0+ react-native bundle –dev false –platform android –entry-file index.js –bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle –assets-dest ./android/app/build/intermediates/res/merged/debug #React-Native 0-0.49.0 react-native bundle –dev false –platform android –entry-file index.android.js –bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle –assets-dest … Read more

Setting environment variable in react-native?

Instead of hard-coding your app constants and doing a switch on the environment (I’ll explain how to do that in a moment), I suggest using the twelve factor suggestion of having your build process define your BASE_URL and your API_KEY. To answer how to expose your environment to react-native, I suggest using Babel’s babel-plugin-transform-inline-environment-variables. To … Read more

Get size of a View in React Native

As of React Native 0.4.2, View components have an onLayout prop. Pass in a function that takes an event object. The event’s nativeEvent contains the view’s layout. <View onLayout={(event) => { var {x, y, width, height} = event.nativeEvent.layout; }} /> The onLayout handler will also be invoked whenever the view is resized. The main caveat … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)