React
小菜101
这个作者很懒,什么都没留下…
展开
-
掌握React的基本使用,重塑前端开发
1. Handling EventsHtml中处理添加事件:<a href="#" onclick="console.log('The link was clicked.'); return false"> Click me</a>React中:function ActionLink() { function handleClick(e) { ...原创 2020-05-07 14:38:39 · 179 阅读 · 0 评论 -
搞懂React的state和生命周期函数(lifecycle methods)
State and Lifecycle何谓stateA component needs state when some data associated with it changes over time. For example, a Checkbox component might need isChecked in its state,组件内部涉及的数据会根据时间条件变化随...原创 2020-04-29 16:04:59 · 471 阅读 · 0 评论 -
Components make life easier(组件复用让生活更美好)
Components and PropsConceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.Co...原创 2020-04-28 14:56:15 · 162 阅读 · 0 评论 -
React的渲染element(做最少的DOM操作)
Rendering ElementsAn element describes what you want to see on the screen.原则:尽可能少的操作DOM如下面react官网的例子就是很好的说明:function tick() { const element = ( <div> <h1>Hello, world!<...原创 2020-04-28 10:03:04 · 413 阅读 · 0 评论 -
React中的JSX和React elements的概念
Introducing JSXJSX语法实际上是在创建对象,产生的对象称为React elements;对这些React elements进行渲染,构建出DOMconst element = ( <h1 className="greeting"> Hello, world! </h1>);// => 等于如下写法:const e...原创 2020-04-27 20:02:40 · 660 阅读 · 0 评论