Skip to content

In-app inspector throws error when assigning percentage strings to padding(like this --> padding: '10%'), although it works in the UI. #17496

@shubhnik

Description

@shubhnik

Is this a bug report?

YES

Have you read the Contributing Guidelines?

YES

Environment

Environment:
OS: macOS Sierra 10.12
Node: 7.5.0
Yarn: 0.20.3
npm: 5.4.2
Watchman: 4.7.0
Xcode: Xcode 8.3.1 Build version 8E1000a
Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.52.0 => 0.52.0

Target Platform: iOS (10.3)

Steps to Reproduce

  1. Use padding with percentage string as: padding: '10%'.
  2. Now open the inspector using in-app developer menu and tap on the element with the given padding
  3. The inspector will error out saying that padding should be a number instead of a string, although padding as a string works in the UI.

Expected Behavior

The inspector shouldn't have thrown an error. It should have work the same way if I have given a padding as a number.

Actual Behavior

React-Native supports padding using percentage strings but the inspector is throwing error that the padding should be a number rather than a string.
simulator screen shot jan 9 2018 10 23 25 am

Reproducible Demo

I have added a padding as a string in this app.js file. Just replace the default app.js file with this one.

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

export default class App extends Component<{}> {
  render() {
    return (
      <View style={styles.container}>
        <View style={{backgroundColor: 'red', flex: 1}}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit App.js
        </Text>
        <Text style={styles.instructions}>
          {instructions}
        </Text>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding:'10%',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

PR opportunity

I think it is a good first bug. I would love to send a PR for this.

Thank You 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugGood first issueInterested in collaborating? Take a stab at fixing one of these issues.Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.Resolution: LockedThis issue was locked by the bot.Resolution: PR SubmittedA pull request with a fix has been provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions