由于 Uncaught ReferenceError 错误,组件未呈现。该错误在 React API 文件之一中引发(请参阅下面有问题的代码)。我正在使用 react-rails gem 并试图渲染一个名为“测试”的空白组件。
来自 React API 的文件(第 3 行)
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.production.min.js');
} else {
module.exports = require('./cjs/react.development.js');
}
ERB 渲染组件
<div style="width:100vw">
<%= react_component('Test') %>
</div>
组件
import React from "react";
import PropTypes from "prop-types";
export default class Test extends React.Component{
render(){
return (
<div>
test
</div>
)
}
}
React API 应该将“测试”呈现给 (v)dom。