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

Update to 0.4.1 - rendering not working for e.g. texts and images #1051

Closed
PhilippKrone opened this issue Apr 28, 2015 · 18 comments · May be fixed by AbhinavJain13/react-native#30
Closed

Update to 0.4.1 - rendering not working for e.g. texts and images #1051

PhilippKrone opened this issue Apr 28, 2015 · 18 comments · May be fixed by AbhinavJain13/react-native#30
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@PhilippKrone
Copy link
Contributor

Hi,

I've just updated to 0.4.1 and each screen is rendering completely wrong, e.g. without images and texts.

Anyone else experiencing the same? After going back to 0.4.0, everything is working again.

Regards
Philipp

@finalquest
Copy link

I've just updated from 0.4 to 0.4.1 and everything works fine, texts and images

@PhilippKrone
Copy link
Contributor Author

Ok, weird.

0.4.0:
ios simulator screen shot 28 apr 2015 21 26 49

0.4.1:
ios simulator screen shot 28 apr 2015 21 28 31

No other changes done in the source code.

@brentvatne
Copy link
Collaborator

@PhilippKrone - just a shot in the dark, did you try restarting XCode?

@PhilippKrone
Copy link
Contributor Author

@brentvatne did not before, but just did - no success. I'll try to create a minimal example, let's see whether my weird behaviour can be localized. :-)

@PhilippKrone
Copy link
Contributor Author

@brentvatne ok, I was able to figure it out, atleast to elimate the error, although I dont know the reason yet.

Old stylesheet (working under 0.4.0 and not working under 0.4.1)

  container: {
    flex: 1,
    justifyContent: 'flex-start',
    alignItems: 'stretch',
    backgroundColor: '#ffffff',
  },

New stylesheet (working under 0.4.0 and 0.4.1)

  container: {
    flex: 1,
    justifyContent: 'flex-start',
    alignItems: 'center',
    backgroundColor: '#ffffff',
  },

So it seems the interpretation of alignItems has changed from 0.4.0 to 0.4.1 - I can now fix the layout again for my app, but the root cause would be of interest for me anyway.

@brentvatne
Copy link
Collaborator

Maybe this?

@PhilippKrone
Copy link
Contributor Author

Mhh, I have to deep dive into this change - from a first look this might be what has caused my issue. Thanks for the hint!

@brentvatne
Copy link
Collaborator

Perhaps not, it looks like that was just some dead code removal (unless it produces some side effects).

@PhilippKrone
Copy link
Contributor Author

Mhh, currently checking:

dd6f774

Anyway, priority is rather low as a solid "work around" / fix can be used.

@brentvatne
Copy link
Collaborator

@PhilippKrone - fair. Could you post the full code or something that will reproduce it so we can determine if the change was a fix or a regression? 😄

@PhilippKrone
Copy link
Contributor Author

@brentvatne Sure thing! :)

  1. Create a new RN project and add a static image in XCODE. I called it "Test" and added the following image: http://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/000080_Navy_Blue_Square.svg/2000px-000080_Navy_Blue_Square.svg.png

  2. use the following source code:

/**
 * Test app
 * https://github.com/facebook/react-native
 */
'use strict';

var React = require('react-native');
var {
  Navigator,
  Text,
  Image,
  View,
  AlertIOS,
  NetInfo,
  TouchableHighlight,
  AppRegistry,
  StyleSheet,
} = React;

var TestProject = React.createClass({
  render: function() {
    return (
      <View style={styles.container}>
       <Image
         style={styles.backdrop}
         source={require('image!Test')}>
         <View style={styles.ClearBackground}>
           <View style={styles.backdropView}>
               <Text style={styles.appNameText}>
                  SMIPE
               </Text>
            </View>
          </View>
        </Image>
     </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'flex-start',
    alignItems: 'center',
    backgroundColor: '#ffffff',
  },
    backdrop: {
      flex: 1,
      marginTop: 0,
      alignItems: 'stretch',
    },
    backdropView: {
      backgroundColor: 'rgba(0,0,0,0)',
      alignItems: 'stretch',
      width: 250,
    },
    ClearBackground: {
      backgroundColor: 'rgba(0,0,0,0)',
      flex: 1,
      alignItems: 'center',
      marginTop: 130,
    },
    appNameText: {
      textAlign: 'center',
      fontSize: 48,
      fontFamily: 'Gill Sans',
      color: '#ffffff',
    },
});

AppRegistry.registerComponent('TestProject', () => TestProject);
  1. Following behaviour:
    RN 0.4.0. for both, "alignItems: 'center'," and "alignItems: 'stretch'" in the container style, it is working
    RN 0.4.1. only for "alignItems: 'center'," it is working, for 'stretch', the text is not visible (I think it is moved somewhere out of the screen as the image has a higher width than the screen?)

@tadeuzagallo
Copy link
Contributor

It's actually related to require, you can test it by setting width and height on the image's style.

/cc @amasad

@amasad
Copy link
Contributor

amasad commented Apr 29, 2015

Might be a regression while we're working on #1043 cc @frantic

@PhilippKrone
Copy link
Contributor Author

Indeed setting the width and height works. I just figured out a case in which I'm only setting the height of an image (and no width, as I want to have the same aspect ratio as the original image) and this is not working correctly as well. I'm now calculating the width as well by just multiplying the calculated height with the (known) aspect ratio and it's working again.

Thanks a lot for all your support!

@frantic
Copy link
Contributor

frantic commented Apr 30, 2015

We started to mix in image width/hight if they are not set on image style. Will probably have to reconsider this - use case when image is sized using flex is valid. @vjeux the layout guru, thoughts?

@JohnyDays
Copy link
Contributor

@frantic or when image is sized using the parent's align-items:'stretch' property, that is also valid imo, and changing it would break my current use case.

@vjeux
Copy link
Contributor

vjeux commented May 1, 2015

Erg yeah, I didn't think of this use case. As a workaround I think you can do style={{width: undefined}}

I'm not such a fan of auto injecting the dimensions but it's worth trying out and see how that works

@bimawa
Copy link
Contributor

bimawa commented May 6, 2015

Guys i have similar troubles, after update on 0.4.1 all my root View flow by width
06 05 15 20 35 08
06 05 15 20 35 11

@facebook facebook locked as resolved and limited conversation to collaborators May 30, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants