You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
akashdotsrivastava
changed the title
console.table does not render single dimension array correctly
console.table does not render one dimensional array correctly
May 10, 2023
Format your table items and use useEffect to initialise things in the right order like this.
// Loading the consoleuseEffect(()=>{functionhandleCallback(logItems: Message[]){setLogs(logItems);}functiontranspose(matrix: Message[][]){if(!matrix||matrix.length===0)return[];consttable=matrix[0]returntable}consthookedConsole=Hook(window.console,(logItems)=>handleCallback([{ ...logItems,data: [transpose(logItems.dataasMessage[][])]}]asMessage[]),false)return()=>{if(hookedConsole){Unhook(hookedConsole)}}},[setLogs])// Keeping it fresh in the consoleuseEffect(()=>{// Debug consoleconstitems={input: [input],outputLength: [output.length],}},[nput,output])return<Consolelogs={logs.logs}filter={['table']}/>
This is the result of
console.table
in Chrome:This is the result when rendering the same using
console-feed
The value column doesn't show up.
This can be seen in this demo as well: https://codesandbox.io/s/console-feed-ziq76t?file=/src/demo/index.js:302-330
The text was updated successfully, but these errors were encountered: