ブラウザウィンドウの高さを取得してその値を
cssとして設定したいのですが、どうやればいいでしょうか・・・
const App = () => ( getDefaultProps() { return { height: 0 } } getInitialState() { return { height: this.props.height } } <div> <PurpleAppBar eventTarget={window} onResize={ (event) => this.setState({ height: event.target.innerHeight }) } /> <section style={{ height:this.state.height }}> <SuccessButton label='Success' primary raised /> <Button label='Primary Button' primary /> </section> <Cardarea /> </div> );
onResizeのところでconsole.log(event.target.innerHeight);
とやるとちゃんとブラウザの高さを変更するたびに数値がでているのですが、
それをsectionのstyleに設定する方法に悩んでいます。
なんとなくsetStateなるものを利用する感じだと思うのですが・・・
上記ですと構文エラーとなります。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。