Skip to content

Calculated width & height on layout, used later on re-rendering. Possibility to change ScrollView styles#548

Merged
arribbar merged 3 commits into
leecade:masterfrom
germanst:master
Sep 28, 2017
Merged

Calculated width & height on layout, used later on re-rendering. Possibility to change ScrollView styles#548
arribbar merged 3 commits into
leecade:masterfrom
germanst:master

Conversation

@germanst

Copy link
Copy Markdown
Contributor

When swiper component is mounted, width and height are calculated and set in state. But if you change to another view in your app (in my case pressing on another tab, I'm using tabs from 'react-native-scrollable-tab-view'), the component is not unmounted, so if you come back to the view which contents swiper component, it is doing this:
initState.width = props.width || width // same with height
and it's not correct, because it should set previously calculated width and height, which is stored in state.
In my case, calculated height was 465 (correct, calculated by onLayout function), but when I came back height was set to 500 (incorrect, given by const { width, height } = Dimensions.get('window'))

I also needed to set style prop to ScrollView, so I added it.

…th and height are calculated, but if you left the view and then come back, those width and height previously calculated are not used and it uses width and height of window instead
@germanst germanst changed the title Calculated width & height on layout, used later or re-rendering. Possibility to change ScrollView styles Calculated width & height on layout, used later on re-rendering. Possibility to change ScrollView styles Aug 31, 2017
@arribbar

arribbar commented Sep 8, 2017

Copy link
Copy Markdown
Collaborator

Thanks @germanst.
It appears you have some conflicts. You might want to check last changes and include them in your code

@germanst

Copy link
Copy Markdown
Contributor Author

@arribbar done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants