International Monetary Fund Says the Philippines to Become Key Crypto Market

New International Monetary Fund paper is focused on the Philippines’ impact on the global crypto industry and vice versa. Read here the entire crypto news report.

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Building Fully customisable view for React Native in Android

React Native provides a bunch of Views that can be used to build user interface. Over 90 percent of the times the default views provided by React Native are enough to build the required UI. But, there will be times when a complex native view needs to be exposed to React Native.

I recently faced such a situation where I had to build a custom view in native and expose to RN. I would like to share my learnings while doing so.

There are two types of communication that is possible in case of RN exposed views. First, native sending an event to RN, this event triggers a callback function at the JS side (something similar to onClick of Touchables). Next is when you need tell native to do somethings based on some event at the JS end (somethings similar to setNativeProps having a view reference). In this article I would like to explain how you can achieve both kind of communication in the RN exposed views. I’ll be explaining things from Android point of view, the things in iOS are quite similar.

I found that these three methods to be enough to have most the required functionality for an RN exposed view.

At the JS end, in order to dispatch a command from RN to native.

The key used for getEventName should match the one used with getExportedCustomDirectEventTypeConstants. The registrationName used for the event needs to used at the RN side to pass the callback method. If the registration name is onTwirl. At the RN side <YourView onTwirl={ <callback-method> } needs to be used to do something when the event is received.

This way one can build fully customisable RN exposed view!

Add a comment

Related posts:

A Different View on White Privilege

White Privilege is a set of words that creates dividing lines. It harbors tension and conjures defensiveness at even its mention. As the racially tense climate of the USA matches July’s scorching…

My Investing Framework

The 401Ks are the only accounts where we invest in index or Mutual Funds. In those, we found the S&P 500 Fund with the lowest expense ratio (usually Vanguard or Fidelity). I began investing in 2011…

7 Easy Ways to Make Money Online for Free

The Internet has made it much easier for anyone to earn money. You no longer have to spend your life searching for suitable employment — there are plenty of online jobs with flexible hours and cash…