Console logging for react?

后端 未结 3 1820
面向向阳花
面向向阳花 2021-01-29 23:31

I\'m super new to React and I\'m trying to get it set up for Meteor and piecing stuff together from other sources too. One of these other sources set up console logging for the

3条回答
  •  醉话见心
    2021-01-30 00:04

    If you want to log inside JSX you can create a dummy component
    which plugs where you wish to log:

    const Console = prop => (
      console[Object.keys(prop)[0]](...Object.values(prop))
      ,null // ➜ React components must return something 
    )
    
    // Some component with JSX and a logger inside
    const App = () => 
      

    imagine this is some component

    imagine another component

    // Render ReactDOM.render( , document.getElementById("react") )
    
    
    

提交回复
热议问题