Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotation bug. #2088

Closed
jasongaare opened this issue Jul 21, 2017 · 5 comments
Closed

Rotation bug. #2088

jasongaare opened this issue Jul 21, 2017 · 5 comments

Comments

@jasongaare
Copy link

I'm working on migrating from v3 to v4 and have one thing I can't sort out. When I rotate my device, the view doesn't resize so I have a portrait screen sitting in a landscape view.

simulator screen shot jul 21 2017 4 27 47 pm

What I'm hoping to do is simply add the style { flex: 1 } to the root view... I think this will resolve my problem. In v3 I was previously able to do this:

<Scene key="root" sceneStyle={{ flex: 1 }}>

With sceneStyle no longer a prop, any easy way to do that in v4? Or is there something I'm missing?

@gscanlon21
Copy link

gscanlon21 commented Jul 22, 2017

React-native won't update a scene unless the state is changed. If the state doesn't change when the screen size does, react-native won't acknowledge the new screen size

You could implement a wrapper view which listens for a layout (orientation) change and adjusts accordingly (or just sets the state)

<View style={styles.wrapper} onLayout={(event) => this.onLayout(event)}>
    ...
</View>

then

export default class Example extends Component {
  constructor (props) {
    super(props)
  }

  onLayout (event) {
    // if (this.state.height) return // Layout was already called
    let {width, height} = event.nativeEvent.layout // Gets the width and height of device screen
    this.setState({height: height, width: width})
  }
}

@aksonov aksonov closed this as completed Jul 25, 2017
@jasongaare
Copy link
Author

jasongaare commented Jul 25, 2017

This didn't fix my issue. I'm not sure where it lies, but manually setting the size of my view DOESN'T change the size of my Root Navigator provided via the navigation libraries (because setting the size of the child doesn't change the size of the parent...)

I'll dig more, but still need help if anyone has any suggestions

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

Could you reproduce it with Example project? I rotated it without any problem, all links were re-centered properly without any additional logic.

@aksonov aksonov reopened this Jul 25, 2017
@jasongaare
Copy link
Author

Thanks for your prompt response.

You can probably leave it closed for now, we've decided to stick with React Native 42 for now, because upgrading breaks all our navigation. Following the migration guide helps, but we've been using router-flux for over a year now so the new changes with moving to v4 are altering too many things for us to address currently.

I will circle back when (a) we make the decision to bite the bullet and upgrade, and (b) when router-flux v4 is more stable.

If I'm still having issues then I'll try to create an example project. Our codebase is pretty complex so it's probably an internal issue somewhere... (but the sceneStyle={{ flex: 1 }} on the root scene in v3 seems to be our solution for the time being.

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

Ok, if you want this issue to be fixed, please reproduce it with Example project from this repo (i.e. fork and modify). Closing it for now.

@aksonov aksonov closed this as completed Jul 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants