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

Warning when setting text style to contentStyle in RkButton #177

Closed
1 of 2 tasks
ksairi opened this issue Nov 11, 2018 · 4 comments
Closed
1 of 2 tasks

Warning when setting text style to contentStyle in RkButton #177

ksairi opened this issue Nov 11, 2018 · 4 comments
Assignees
Labels
🐛 Bug 📱 Components components module-specific

Comments

@ksairi
Copy link

ksairi commented Nov 11, 2018

Issue type

I'm submitting a ...

  • bug report
  • feature request

Issue description

Current behavior:
I'm getting a warning when I'm setting the style to RkButton. I'm setting color, fontSize and fontFamily to contentStyle which I think is correct and getting a warning of invalidad prop (color) but it will complain about the others if I comment the first one. The style is applied though!
This wasn't happening until I upgraded to the last version of the library.

Literal warning:
Warning: Failed prop type: Invalid props.contentStyle key color supplied to RkButton.

Bad object:{
"color":"white",
"fontSize":19,
"fontFamily":"lato-regular"
}

Expected behavior:
No warnings at all

Related code:

import React from 'react';
import { RkButton } from 'react-native-ui-kitten';

const styles = {
	buttonStyle: {
		backgroundColor: '#6b35e3',
		flex: 1
	},
	buttonContent: {
		color: 'white',
		fontSize: 19,
		fontFamily: 'lato-regular'
	}
};

export default class GenericButton extends React.PureComponent {
	render() {
		var shapeType = 'rounded';
		if (this.props.shapeType) {
			shapeType = this.props.shapeType;
		}
		return (
			<RkButton
				rkType={shapeType}
				style={[styles.buttonStyle, this.props.style]}
				contentStyle={[styles.buttonContent, this.props.contentStyle]}
				onPress={this.props.onPress}>
				{this.props.text}
			</RkButton>
		);
	}
}

Other information:

I'm using the expo client for debugging.
OS, device, package version

	"dependencies": {
		"expo": "31.0.0",,
		"react": "16.5.0",
		"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz"
		"react-native-ui-kitten": "3.1.2"
}
@artyorsh
Copy link
Collaborator

artyorsh commented Nov 11, 2018

Hi @ksairi
Thanks for using our framework and for bug report!

I've tried running your code, but not sure I'm using the same environment because for now we're working on new version of ui-kitten. Btw, I got no warning.
I suppose this is caused by RkButton contentStyle propType definition. Can you please try changing it to contentStyle: RkText.propTypes.style right in your installed node_modules and describe here if something changed?
If it works correctly, feel free to create a PR and a become contributor :) Thanks!

@artyorsh artyorsh added 📱 Components components module-specific 🐛 Bug labels Nov 11, 2018
@artyorsh artyorsh self-assigned this Nov 11, 2018
@ksairi
Copy link
Author

ksairi commented Nov 11, 2018

Hi @artyorsh. I tried that and is working. I will submit the PR but I don't understand why the warning if the proptype of RkButton contentStyle was style and the properties color, fontSize, fontFamily belong to that object.

@copleykj
Copy link

copleykj commented Nov 12, 2018

I'm getting the same warning on my project..

[21:36:37] Warning: Failed prop type: Invalid props.contentStyle key `fontWeight` supplied to `RkButton`.
Bad object: {
  "fontWeight": "bold"
}
Valid keys: [
  "display",
  "width",
  "height",
  "start",
  "end",
  "top",
  "left",
  "right",
  "bottom",
  "minWidth",
  "maxWidth",
  "minHeight",
  "maxHeight",
  "margin",
  "marginVertical",
  "marginHorizontal",
  "marginTop",
  "marginBottom",
  "marginLeft",
  "marginRight",
  "marginStart",
  "marginEnd",
  "padding",
  "paddingVertical",
  "paddingHorizontal",
  "paddingTop",
  "paddingBottom",
  "paddingLeft",
  "paddingRight",
  "paddingStart",
  "paddingEnd",
  "borderWidth",
  "borderTopWidth",
  "borderStartWidth",
  "borderEndWidth",
  "borderRightWidth",
  "borderBottomWidth",
  "borderLeftWidth",
  "position",
  "flexDirection",
  "flexWrap",
  "justifyContent",
  "alignItems",
  "alignSelf",
  "alignContent",
  "overflow",
  "flex",
  "flexGrow",
  "flexShrink",
  "flexBasis",
  "aspectRatio",
  "zIndex",
  "direction",
  "shadowColor",
  "shadowOffset",
  "shadowOpacity",
  "shadowRadius",
  "transform",
  "transformMatrix",
  "decomposedMatrix",
  "scaleX",
  "scaleY",
  "rotation",
  "translateX",
  "translateY",
  "backfaceVisibility",
  "backgroundColor",
  "borderColor",
  "borderTopColor",
  "borderRightColor",
  "borderBottomColor",
  "borderLeftColor",
  "borderStartColor",
  "borderEndColor",
  "borderRadius",
  "borderTopLeftRadius",
  "borderTopRightRadius",
  "borderTopStartRadius",
  "borderTopEndRadius",
  "borderBottomLeftRadius",
  "borderBottomRightRadius",
  "borderBottomStartRadius",
  "borderBottomEndRadius",
  "borderStyle",
  "opacity",
  "elevation"
]

Can confirm that changing contentStyle to RkText.propTypes.style fixes the warning.

@artyorsh
Copy link
Collaborator

@ksairi,
The bug was that the prototype of described style belongs to style of View, so that you can't apply fontSize to it

ufolux added a commit to ufolux/react-native-ui-kitten that referenced this issue Nov 19, 2018
Replace the type of `contentStyle` from `ViewPropTypes.style` to `RkText.propTypes.style` to resolve the [issue#177](akveo#177)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug 📱 Components components module-specific
Projects
None yet
Development

No branches or pull requests

3 participants