[英]spread operator is not working in react as {…this.state.attributes}
I am facing issue unexpected token this as ...this is not working as attribute in React. 我面临问题意外的令牌,因为...这在React中不能作为属性。
<button {...this.state.attributes}> Save </button>
this has value in this scope. 在此范围内具有价值。 Thanks in advance. 提前致谢。
Regards, Shraddha Agrawal 此致Shraddha Agrawal
Might be even a typo ...this and not ..this. 甚至可能是错字...这不是..这。 See below. 见下文。
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
state = {className:"button", style:{color: 'red'}}
render() {
return (
<div>
<h1>Hello World</h1>
<button {...this.state}>Hello World</button>
</div>
);
}
}
export default App;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.