我有这个反应组件.这不是正确呈现,但得到一个恼人的警告,如
函数作为React子函数无效.如果您返回Component而不是渲染,则可能会发生这种情况.或许你打算调用这个函数而不是返回它.
这是我的组件.我在这做错了什么?
import React, { Component } from 'react';
class Squares extends Component {
constructor(props){
super(props);
this.createSquare = this.createSquare.bind(this);
}
createSquare() {
let indents = [], rows = this.props.rows, cols = this.props.cols;
let squareSize = 50;
for (let i = 0; i < rows; i++) {
for (let j = 0; i < cols; j++) {
let topPosition = j * squareSize;
let leftPosition = i * squareSize;
let divStyle = {
top: topPosition+'px',
left: leftPosition+'px'
};
indents.push(<div style={divStyle}></div>); …Run Code Online (Sandbox Code Playgroud) 我想在 HTML5 画布中绘制一条像这里提到的曲线。有人可以指出我应该使用什么方法吗?