Lowie Huyghe
Lowie Huyghe

Reputation: 275

Native Android UI Component not updating

I'm having issues with a Native UI Component that is used in React-Native. The situation is that I have an existing, functioning, completed layout in Android that I need to reuse in a react-native view.

The existing layout (in Android):

To expose this existing layout and use it in React-Native I did as told by the docs. Exposing properties, callbacks or events was not required as the existing layout is closed and works as is.

The React-Native view:

The problem occurs when the data is loaded. With debugging you can see that the code is run to update the layout, but that is visually not shown. The loading-layout keeps showing, until you perform a scroll-gesture which redraws the screen and shows the RecyclerView with the loaded data. As if the RecyclerView was already there but just not showing.

Would anybody know what could be the problem?

Thanks is advance!

Upvotes: 1

Views: 474

Answers (1)

Flavio_Lima
Flavio_Lima

Reputation: 155

try adding this function, and change base_svg to the iew that you disered :

private final Runnable measureAndLayout = new Runnable() {
        @Override
        public void run() {
            base_svg.measure(
                    View.MeasureSpec.makeMeasureSpec(base_svg.getWidth(), View.MeasureSpec.EXACTLY),
                    View.MeasureSpec.makeMeasureSpec(base_svg.getHeight(), View.MeasureSpec.EXACTLY));
            base_svg.layout(base_svg.getLeft(), base_svg.getTop(), base_svg.getRight(), base_svg.getBottom());
        }
    };

After you add the new information to the screen call that function this way:

    base_svg.post(measureAndLayout);

Check if it renders the new views that you add or remove.

To be honest I don't know the reason why. but this work for me. I think react is forcing you to just to render when react wants. Check this issue for more understanding.

Upvotes: 2

Related Questions