Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

reactjs - ionic react getting screen width dynamically

i am using ionic react and struggling on how to use calcWidth to get the width dynamically. Currently i am using something like below

width={310}

which gives 310 px in my react component i am using. the documentation suggest to use calcWidth but does not explain how. I see some examples to use Dimensions but seems i could not use that with ionic react.

i tried plain

width={calcWidth} 

but that does not work as it will need the width property.

question from:https://stackoverflow.com/questions/66057542/ionic-react-getting-screen-width-dynamically

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Well you can obtain the screen width by using the window:

window.innerWidth

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...