// git log --pretty=improvements
Veja como um código evolui da versão inicial até a melhor prática atual, commit por commit — como um git log animado com métricas de qualidade em tempo real.
1class UserProfile extends React.Component {2constructor(props) {3super(props)4this.state = {5user: null,6loading: true,7error: null8}9}1011componentDidMount() {12fetch('/api/user/' + this.props.id)13.then(res => res.json())14.then(data => {15this.setState({ user: data, loading: false })16})17.catch(err => {18this.setState({ error: err, loading: false })19})20}2122componentDidUpdate(prevProps) {23if (prevProps.id !== this.props.id) {24this.setState({ loading: true })25fetch('/api/user/' + this.props.id)26.then(res => res.json())27.then(data => {28this.setState({ user: data, loading: false })29})30}31}3233render() {34if (this.state.loading) return <p>Loading...</p>35if (this.state.error) return <p>Error!</p>36return <div>{this.state.user.name}</div>37}38}
Next.js App Router, React Patterns, TypeScript e Git: mais guias práticos na seção Dicas.