从反应原因DOM引用获取clientHeight [英] Getting clientHeight from a react-reason DOM ref

查看:114
本文介绍了从反应原因DOM引用获取clientHeight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在访问 reason-react DOM参考,以确定客户端的高度.

I'm accessing a reason-react DOM reference in order to ascertain client height.

不幸的是, clientHeight 似乎不是 ref API的一部分.所以这失败了:

Unfortunately clientHeight doesn't seem to be part of the ref API. So this fails:

ref
  -> React.Ref.current
  -> Js.Nullable.toOption
  -> Belt.Option.map(this => {
    React.Ref.clientHeight(this);
});

在React.Ref 中找不到值clientHeight.

The value clientHeight can't be found in React.Ref.

有没有办法从ref提取组件的高度?

Is there a way to extract the height of a component from the ref?

裁判是从一个div获得的.

The ref was acquired from a div.

推荐答案

假设您从 ReactDOMRe.Ref.domRef ReactDOMRe.Ref.callbackDomRef 获取了该引用,您将收到一个 Dom.element ,并可以使用来自Element.clientHeight "rel =" nofollow noreferrer> bs-webapi :

Assuming you acquired the ref from either ReactDOMRe.Ref.domRef or ReactDOMRe.Ref.callbackDomRef, you will receive a Dom.element and can use Element.clientHeight from bs-webapi:

open Webapi.Dom;

ref
  -> React.Ref.current
  -> Js.Nullable.toOption
  -> Belt.Option.map(Element.clientHeight);

这篇关于从反应原因DOM引用获取clientHeight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆