deltanovember
deltanovember

Reputation: 44051

In react-native, why am I unable to define the width of my component?

With reference to the following Snack:

https://snack.expo.io/@deltanovember/shallow-scone

my Picker has an <Icon /> that aren't properly aligned:

The image of issue

I've tried to fix this by fixing the width of the Picker to assign this style :

style={{ width: 100 }}

but the <Icon /> still aren't aligning.

How can I get my <Icon /> to align ?

Upvotes: 1

Views: 45

Answers (1)

MoHammaD ReZa DehGhani
MoHammaD ReZa DehGhani

Reputation: 585

you should set width style to your picker like this :

style={{ width: '100%' }}

I try it in expo and it fixed :)

about the question mark it happened when you set the icon name wrong!

you can use this website to search in Icon names :

https://oblador.github.io/react-native-vector-icons/

Extra

you can get the screen width and use it where ever u want in your project like this :

import { Dimensions } from 'react-native'
const { width: WIDTH } = Dimensions.get('window')

Upvotes: 3

Related Questions