Create React App 3.0.0发布,支持 Hooks

栏目: 服务器 · 发布时间: 6年前

内容简介:Create React App 3.0.0 发布了,Create React App 是由 Facebook 推出的脚手架,基本可以零配置搭建基于 webpack 的 React 开发环境,并内置了热更新等功能。此版本带来了一些新功能:其中最大的亮点是支持 Hooks。Hooks 是 React 16.8 中引入的新功能,允许在不编写类的情况下使用状态和其它 React 功能。以下是一个名为 useState 的 Hook 示例:

Create React App 3.0.0 发布了,Create React App 是由 Facebook 推出的脚手架,基本可以零配置搭建基于 webpack 的 React 开发环境,并内置了热更新等功能。

此版本带来了一些新功能:

  • Jest 24
  • 支持 Hooks
  • TypeScript linting
  • @babel/preset-env 支持 browserslist
  • 使用 jsconfig.json/tsconfig.json 进行绝对路径导入

其中最大的亮点是支持 Hooks。Hooks 是 React 16.8 中引入的新功能,允许在不编写类的情况下使用状态和其它 React 功能。以下是一个名为 useState 的 Hook 示例:

import React, { useState } from 'react';

function Example() {
  // Declare a new state variable, which we'll call "count"
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}

完整更新内容查看更新说明:


以上所述就是小编给大家介绍的《Create React App 3.0.0发布,支持 Hooks》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web ReDesign 2.0

Web ReDesign 2.0

Kelly Goto、Emily Cotler / Peachpit Press / 2004-12-10 / USD 45.00

If anything, this volume's premise--that the business of Web design is one of constant change-has only proven truer over time. So much so, in fact, that the 12-month design cycles cited in the last ed......一起来看看 《Web ReDesign 2.0》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具