我正在访问一个reason-react DOM引用,以确定客户端高度。
不幸的是,clientHeight似乎不是ref应用编程接口的一部分。所以这是失败的:
ref
-> React.Ref.current
-> Js.Nullable.toOption
-> Belt.Option.map(this => {
React.Ref.clientHeight(this);
});The value clientHeight can't be found in React.Ref。
有没有办法从引用中提取元件的高度?
ref是从div获取的。
发布于 2019-09-23 17:49:02
假设您从ReactDOMRe.Ref.domRef或ReactDOMRe.Ref.callbackDomRef获取了ref,您将收到一个Dom.element,并且可以使用来自bs-webapi的Element.clientHeight
open Webapi.Dom;
ref
-> React.Ref.current
-> Js.Nullable.toOption
-> Belt.Option.map(Element.clientHeight);https://stackoverflow.com/questions/58053827
复制相似问题