React Native

React Native Module 에서 데이터 Callback 시 Type 에러..

Machine_웅 2022. 11. 17. 09:31
728x90
반응형
private WritableArray getDataAsArray(FirebaseVisionText firebaseVisionText) {
    WritableArray data = Arguments.createArray();
    WritableMap info = Arguments.createMap();
    WritableMap coordinates = Arguments.createMap();

    for (FirebaseVisionText.TextBlock block: firebaseVisionText.getTextBlocks()) {
        info = Arguments.createMap();
        coordinates = Arguments.createMap();

        Rect boundingBox = block.getBoundingBox();

        coordinates.putInt("top", boundingBox.top);
        coordinates.putInt("left", boundingBox.left);
        coordinates.putInt("width", boundingBox.width());
        coordinates.putInt("height", boundingBox.height());

        info.putMap("bounding", coordinates);
        info.putString("text", block.getText());
        data.pushMap(info);
    }

    return data;
}

 

앱에서 -> JS로 콜백을 보내는 경우에는 WritableArray에 담아서.. 보내야 한다...

728x90
반응형