import React.Component from 'react' import [ Component ] from 'react' import Component from 'react' import { Component } from 'react' React.memo高阶组件将其包装起来。 useReducer Hook。 useMemo Hook。 shouldComponentUpdate生命周期方法。 const person =(firstName, lastName) =>
{
first: firstName,
last: lastName
}
console.log(person("Jill", "Wilson"))
import React, {useState} from 'react';
const name = 'Rachel'; const age = 31; const person = { name, age }; console.log(person);
{{name: "Rachel", age: 31}} {name: "Rachel", age: 31} {person: "Rachel", person: 31}} {person: {name: "Rachel", age: 31}} const topics = ['cooking', 'art', 'history'];
const first = ["cooking", "art", "history"] const [] = ["cooking", "art", "history"] const [, first]["cooking", "art", "history"] const [first] = ["cooking", "art", "history"] const [, , animal] = ['Horse', 'Mouse', 'Cat']; console.log(animal);
<Message {...props} />
<Route path="/:id" />
function Dish() {
return <h1>Mac and Cheese</h1>;
}
ReactDOM.render(<Dish />, document.getElementById('root'));
div h1 React.createElement('h1', null, "What's happening?");
<h1 props={null}>What's happening?</h1> <h1>What's happening?</h1> <h1 id="component">What's happening?</h1> <h1 id="element">What's happening?</h1> function MyComponent() {
return (
<Suspense>
<div>
<Message />
</div>
</Suspense>
);
}
const message = 'Hi there'; const element = <p>{message}</p>;
useLayoutEffect?来源 "useLayoutEffect是useEffect的一个版本,它在浏览器重绘屏幕之前触发。"
A. <button onClick={this.handleClick}>Click Me</button>
B. <button onClick={event => this.handleClick(event)}>Click Me</button>