简体   繁体   English

在哪里写console.log里面的组件? 反应

[英]Where to write console.log inside component ? react

I need to check my variables:我需要检查我的变量:

  return (
    <FileInfo> 
      <div>
        <FileSize>{fileSize}</FileSize> 
      </div>
    </FileInfo>
  );
};

const FilesContainer = ({ intl, files, onClickHandler, fullWidth }) => (
  <Container>
    <Label>
      {files} 
    </Label> 
  </Container>
);
 

I need to check my:我需要检查我的:

const FilesContainer = ({ intl, files, onClickHandler, fullWidth }) => ( const FilesContainer = ({ intl, files, onClickHandler, fullWidth }) => (

my files variable... when I console.log('files', files) bellow example:我的文件变量...当我 console.log('files', files) 下面的例子:

const FilesContainer = ({ intl, files, onClickHandler, fullWidth }) => (
  console.log('files' , files)
  <Container>
    <Label>
      {files} 
    </Label> 
  </Container>
);

I got error...how to check var?我收到错误...如何检查 var?

Instead of implicit inline return, Use the function block and add console logs before the return statement.代替隐式内联返回,使用 function 块并在返回语句之前添加控制台日志。

const FilesContainer = ({ intl, files, onClickHandler, fullWidth }) => {
  console.log("files", files);
  return (
    <Container>
      <Label>{files}</Label>
    </Container>
  );
};

Missing comma:缺少逗号:

const FilesContainer = ({ intl, files, onClickHandler, fullWidth }) => (
  console.log('files' , files),
  <Container>
    <Label>
      {files} 
    </Label> 
  </Container>
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 里面的console.log<errormessage> 零件</errormessage> - console.log inside <ErrorMessage> component console.log 显示数据但在 if 条件 javascript 中出错(使用内部反应组件) - console.log showing data but getting error in if condition javascript (using inside react component) 为什么 `Promise.then` 在 React 组件中被调用两次,而不是在 console.log 中? - Why is `Promise.then` called twice in a React component but not the console.log? 为什么在React Component构造函数中的console.log(super)会抛出错误? - Why console.log(super) in React Component constructor throw an Error? 什么是react组件显示的render方法中的console.log? - What is console.log in the render method of a react component showing? 在React构造函数中未调用Console.Log - Console.Log Not Being Called Inside React Constructor console.log() 没有在间隔内记录到控制台 - console.log() not logging to console inside interval 在功能组件中,我应该在哪里放置 console.log 来测试组件是否重新呈现? - In a functional component, where would I place a console.log to test if the component rerenders? Console.log与document.write - Console.log vs document.write 将console.log()写入AngularJS中的命令行 - Write console.log() to the command line in AngularJS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM