学习react难免需要定义变量
在函数组件中 app.js
import React from 'react'
const App = () => {
const name = 'hello world'
return (
<div>{name}</div>
)
}
export default App
在class组件定义变量 app.jsx
import React from "react";
class App extends React.Component {
constructor (){
super()
this.state ={
title:"hello world"
}
}
render() {
const {title} = this.state
return (
<div>
{title}
</div>
);
}
}
export default App