小编Fer*_*oya的帖子

如何访问BaseComponent的ref或任何级别的组件?

原始问题:https://github.com/acdlite/recompose/issues/232

如何访问BaseComponent的ref或任何级别的组件?

码:

class BaseComponent {
    doSth(){...}
}
const Component compose(...some)(BaseComponent);

class App {
    componentDidMount() {
        // undefined(doSth) is not a function
        this.refs.component.doSth();
    }
    render() {
        <Component ref="component" />
   }
}
Run Code Online (Sandbox Code Playgroud)

reactjs recompose

5
推荐指数
1
解决办法
1246
查看次数

如何为Js.Dict.get使用Js.Dict.t类型

我试图将一些JS转换为Reason,沿着我需要键入JSON响应的方式,并检查对象中是否存在键.

这是我目前的代码:

let api_key = "";
let api_url = "http://ws.audioscrobbler.com/2.0";
let method = "user.getRecentTracks";
let user = "montogeek";

type trackAttr = {
  nowplaying: bool
};

type artistT = {
  text: string
}

type trackT = {
  attr: trackAttr,
  name: string,
  artist: artistT
};

type recentTrackT = {
  track: array(Js.Dict.t(trackT))
};

type response = {
  recenttracks: recentTrackT
};

Js.Promise.(Fetch.fetch(api_url ++ "?method=" ++ method ++ "&" ++ user ++ "=" ++ user ++ "&limit=1&format=json&api_key=" ++ api_key)
    |> then_(Fetch.Response.json)
    |> then_(json: response => …
Run Code Online (Sandbox Code Playgroud)

types reason bucklescript

3
推荐指数
1
解决办法
340
查看次数

标签 统计

bucklescript ×1

reactjs ×1

reason ×1

recompose ×1

types ×1