[RN] - processColor API

April 25, 2018
Color string meet native code
tool

import { processColor } from 'react-native';

This is not the typical API you will use when working with React Native.

When working with iOS libraries, chances are you will need to use UIColor, and that's when you can use processColor.

I am researching for drawing board application written in React Native, and came across this package.

https://github.com/terrylinla/react-native-sketch-canvas

Out of curiosity on how it was done, I started digging into the implementation.

So we can pass processColor('#00FFFF') in the argument and it is ready to be accepted as (UIColor*) colorVar in RCT_EXPORT_METHOD.

Refer processColor usage in React Native.

and corresponding native method in iOS.

It is glad to know that such API exist, it will definitely come in handy when bridging native code.

Sure it has different usage worth exploring.


For those who are curious. Check out the implementation of processColor over here.