小编sfl*_*low的帖子

为什么Flow无法使用document.getElementById(...)调用ReactDOM.render

我在Flow类型检查中得到了以下错误.

Cannot call ReactDOM.render with document.getElementById(...) bound to container because null [1] is
incompatible with Element [2].

     src/index.js
      26?       </Switch>
      27?     </ScrollToTop>
      28?   </BrowserRouter>
      29? </Provider>, document.getElementById("root"));
      30?

     /private/tmp/flow/flowlib_174a8121/dom.js
 [1] 646?   getElementById(elementId: string): HTMLElement | null;

     /private/tmp/flow/flowlib_174a8121/react-dom.js
 [2]  18?     container: Element,
Run Code Online (Sandbox Code Playgroud)

代码如下.

// @flow
"use strict";
import React from "react";
import ReactDOM from "react-dom";
import {createStore, applyMiddleware} from "redux";
import {Provider} from "react-redux";
import {BrowserRouter, Switch, Route} from "react-router-dom";
import Home from "./components/home";
import Detail from "./components/detail";
import LevelOfGame from …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs flowtype

14
推荐指数
2
解决办法
3596
查看次数

如何使React Material-UI中的GridList组件响应

我正在使用Material-UI版本1在我的React应用程序中制作网格UI。我想使网格响应。GridList组件API具有cols属性,默认情况下为2

例如,如下所示。

<GridList cols={1} spacing={32} className="list"></GridList>
Run Code Online (Sandbox Code Playgroud)

我可以动态更改道具吗?还是有其他方法使其具有响应性?

reactjs material-ui responsive

8
推荐指数
3
解决办法
6593
查看次数

在 React Native Android 中未指定 compileSdkVersion 错误

当我尝试在 React Native 项目中构建 Android 应用程序时出现构建错误。

当我运行时react-native run-android,它说:

> Configure project :react-native-os
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-os'.
> compileSdkVersion is not specified.
Run Code Online (Sandbox Code Playgroud)

在 Android Studio 中,我可以看到它说的是同样的话: Cause: compileSdkVersion is not specified.

所以我在 Android Studio 中编辑了 build.gradle(Module: app) 文件,但问题仍然存在,错误信息没有改变。

android { …
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin react-native react-native-android

5
推荐指数
2
解决办法
2万
查看次数