[React & Debug] Quick way to debug Stateless component
For example we have the following code:
const TodoList = (props) => (
<div className="Todo-List">
<ul>
{props.todos.map(todo => <TodoItem key={todo.id} {...todo} />)}
</ul>
</div>
)
Because we wrote as function component, it is using the implicit return. To debug what props have been passed in. we can add console.log before the function:
const TodoList = (props) => console.log(props) || (
<div className="Todo-List">
<ul>
{props.todos.map(todo => <TodoItem key={todo.id} {...todo} />)}
</ul>
</div>
)
Because console.log return "underfined", so in the end, it will also run the function to render the statless component.
[React & Debug] Quick way to debug Stateless component的更多相关文章
- React Native填坑之旅--Stateless组件
Stateless component也叫无状态组件.有三种方法可以创建无状态组件. 坑 一般一个组件是怎么定义的: 很久以前的方法: const Heading = createClass({ re ...
- [Recompose] Add Local State to a Functional Stateless Component using Recompose
Learn how to use the 'withState' and 'withHandlers' higher order components to easily add local stat ...
- react 创建组件 (四)Stateless Functional Component
上面我们提到的创建组件的方式,都是用来创建包含状态和用户交互的复杂组件,当组件本身只是用来展示,所有数据都是通过props传入的时候,我们便可以使用Stateless Functional Compo ...
- [React] displayName for stateless component
We can use 'displayName' on component to change its component tag in dev tool: import React from 're ...
- 3.React Native在Android中自己定义Component和Module
React Native终于展示的UI全是Native的UI.将Native的信息封装成React方便的调用. 那么Native是怎样封装成React调用的?Native和React是怎样交互的? V ...
- 【Debug 报异常】Debug打断点报错
用DEBUG启动项目,项目中打断点的,然后会报异常 解决方法: 第一步: 项目-->Java编译器-->Classfile Generation 复选框 全部勾选 第二步: 替换当前文件运 ...
- react 函数子组件(Function ad Child Component)
今天学习了react中的函数子组件的概念,然后在工作中得到了实际应用,很开心,那么好记性不如烂笔头,开始喽~ 函数子组件(FaCC )与高阶组件做的事情很相似, 都是对原来的组件进行了加强,类似装饰者 ...
- Xcode DEBUG宏定义,debug和release模式的选择
设置DEBUG, 使用宏定义: #if DEBUG NSLog(@"debug model"); #else //执行release模式的代码 #endif
- [React] Forward a DOM reference to another Component using forwardRef in React 16.3
The function forwardRef allows us to extract a ref and pass it to its descendants. This is a powerfu ...
随机推荐
- nginx编译安装选项说明
configure 脚本确定系统所具有一些特性,特别是 nginx 用来处理连接的方法.然后,它创建 Makefile 文件. configure 支持下面的选项: –prefix= <path ...
- 破解root用户密码 -rwx权限
破解root用户密码(本地登录) 1.光驱要放入系统光盘 2.重启os 3.修改启动菜单进入1运行级别 4.设置新密码 5.重启os linux的运行级别(默认3或5): 查看默认的运行级别 cat ...
- qt hex to dec
QString s = "32FE12AD"; quint8 u8vlaue = 0; sscanf(s.toStdString().c_str(), ...
- 洛谷 P2309 loidc,卖卖萌
P2309 loidc,卖卖萌 题目背景 Loidc萌萌哒. 他最近一直在靠卖萌追求他的真爱——vivym,经过几轮攻势后vivym酱眼看就要被他所攻略.擅长数据结构的vivym决定利用强大的数据结构 ...
- 菜鸟nginx源代码剖析数据结构篇(七) 哈希表 ngx_hash_t(下)
菜鸟nginx源代码剖析数据结构篇(七) 哈希表 ngx_hash_t(下) Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:B ...
- LintCode 二叉树的遍历 (非递归)
前序: class Solution { public: /** * @param root: The root of binary tree. * @return: Preorder in vect ...
- Java Swing设置主窗体位置居中方法
01.第一种方法 int windowWidth = frame.getWidth(); //获得窗体宽 int windowHeight = frame.getHeight(); //获得窗体高 ...
- 九度 题目1154:Jungle Roads
题目描写叙述: The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid mon ...
- 3.cocos代码入口
模拟代码进入过程: main.cpp #include <iostream> #include "AppDelegate.h" #include "CCApp ...
- POJ 3050 枚举+dfs+set判重
思路: 枚举+搜一下+判个重 ==AC //By SiriusRen #include <set> #include <cstdio> using namespace std; ...