我想为执行此操作的函数创建一个文件 (function.js):
let i = 0;
if (this === that) {
i = 0;
} else {
i = 1;
}
然后我想将它添加到 (this.js)
import function from "./function";
class Example extends Component {
state = {
test
};
render() {
function()
return (
<div>
<h1>{this.state.test.sample[i].name}</h1>
</div>