Skip to content

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

Closed
AbhinavJain13/react-native
#30

Description

@PhilippKrone

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

Activity

  1. finalquest commented on Apr 28, 2015

    @finalquest

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

  2. PhilippKrone commented on Apr 28, 2015

    @PhilippKrone
    ContributorAuthor

    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.

  3. brentvatne commented on Apr 28, 2015

    @brentvatne
    Collaborator

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

  4. PhilippKrone commented on Apr 28, 2015

    @PhilippKrone
    ContributorAuthor

    @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. :-)

  5. PhilippKrone commented on Apr 28, 2015

    @PhilippKrone
    ContributorAuthor

    @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.

  6. brentvatne commented on Apr 28, 2015

    @brentvatne
    Collaborator
  7. PhilippKrone commented on Apr 28, 2015

    @PhilippKrone
    ContributorAuthor

    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!

  8. brentvatne commented on Apr 28, 2015

    @brentvatne
    Collaborator

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

  9. PhilippKrone commented on Apr 28, 2015

    @PhilippKrone
    ContributorAuthor

    Mhh, currently checking:

    dd6f774

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

  10. brentvatne commented on Apr 28, 2015

    @brentvatne
    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? 😄

  11. PhilippKrone commented on Apr 28, 2015

    @PhilippKrone
    ContributorAuthor

    @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?)
  12. tadeuzagallo commented on Apr 28, 2015

    @tadeuzagallo
    Contributor

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

    /cc @amasad

  13. amasad commented on Apr 29, 2015

    @amasad
    Contributor

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

  14. PhilippKrone commented on Apr 29, 2015

    @PhilippKrone
    ContributorAuthor

    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!

  15. frantic commented on Apr 30, 2015

    @frantic
    Contributor

    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?

  16. JohnyDays commented on Apr 30, 2015

    @JohnyDays
    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.

  17. vjeux commented on May 1, 2015

    @vjeux
    Contributor

    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

  18. bimawa commented on May 6, 2015

    @bimawa
    Contributor

    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

  19. locked as resolved and limited conversation to collaborators on May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions