octopitus / rn-sliding-up-panel

Draggable sliding up panel implemented in React Native https://octopitus.github.io/rn-sliding-up-panel/
MIT License
928 stars 157 forks source link

Simple Example Fails to Work on Android #154

Open stiofand opened 4 years ago

stiofand commented 4 years ago

Expo 35 react native app, using mobx, rn-sliding up library simple example works on IOS (very poorly) but not at all on Android, it attempts to render, but the background does not show. No error messages or logs given

Android 8.0, 8.1 and 9 tested 4 different devices, 2 hardware 2 virtual all 4 g ram

Assume all basic App Scaffold components are fine, variables are not null and correct, and an event is fired from a click on a google map component successfully passing visible property Example

const panelRef = useRef(null)
return <SlidingUpPanel
        visible={visible}
        startCollapsed={true}
        showBackdrop={false}
        ref={panelRef}
        allowDragging={true}
        onRequestClose={() => RootStore.updateVisible(false)}>
        <View style={{
            zIndex: 1001,
            width: '100%',
            height: '100%',
            flex: 1,
            backgroundColor: 'white',
            justifyContent: 'center',
            alignItems: 'center'
        }}><Text>Test</Text></View>

IOS OK Screenshot 2019-12-04 at 17 13 15

Andorid, no full render, though it began as the search bar in the map is no longer present (its controlled by the visiblity property too) Screenshot 2019-12-04 at 17 14 46

octopitus commented 4 years ago

Seems like you are using the old version? From v2, you don't need to pass any of those props. It's simply:

const ref = useRef(null);
// Later on you can call ref.current.show()
return <SlidingUpPanel ref={ref}>{...}</SlidingUpPanel>

Read more from the docs.

stiofand commented 4 years ago

So how do you set visibility, close action and draggable behaviour then? Even with these items removed, the issue persists.

Your explanation still does not explain why it runs on IOS and not Android.

Updating to your suggestion, I now have this:

Screenshot 2019-12-04 at 17 58 44

stiofand commented 4 years ago

This issue now also occurs on IOS,

jsdaniell commented 4 years ago

I'm with the same problem, but testing on IOS

import React, { useEffect, useRef } from 'react';
import { View } from 'react-native';
import SlidingUpPanel from 'rn-sliding-up-panel';
import Text from '../Texts/Text';

const QuestionSlidePanel = ({
  mainStore, state, mainAction, secondaryAction, title, description
}) => {
  const _panel = useRef(null);

  useEffect(() => {
    togglePanel(true);
  }, [state]);

  const togglePanel = (condition) => {
    console.log('PANEL: ', condition);

    if (condition) {
      _panel.current.show();
    } else {
      _panel.current.hide();
    }
  };

  return (
    <SlidingUpPanel ref={_panel}>
      <View style={{
        height: 200,
        backgroundColor: 'blue'
      }}
      >
        <Text text="Test" />
      </View>
    </SlidingUpPanel>
  );
};

export default QuestionSlidePanel;

Don't render, even the default state variable is true

jsdaniell commented 4 years ago

I think that the problem is that you have to put the slide panel component down to the tree of components of the main view like:

<View>
// others components
<SlidingUpPanel />
</View>