0

I have this code right here, that works in this online text editor: https://codesandbox.io/s/o4n0v203vy

In the npm console, everything is okay:

enter image description here

But in the browser, this happens:

enter image description here

What logs in the console, when i do export var renderTree = (node, setActiveNode, activeNode) => { console.log(node && node.type, 'look here');

enter image description here

I can't figure out why is this happening. Any help is appreciated! Thanks!

10
  • Are you using the same dummy data? Commented Apr 23, 2018 at 13:39
  • @Colin what do you mean? Commented Apr 23, 2018 at 13:41
  • You have dummy data in the Codesandbox. Are you using dummy data locally too? If not, please post that data here. Commented Apr 23, 2018 at 13:42
  • @Colin ah yes, i'm using the same dummy data. Commented Apr 23, 2018 at 13:43
  • Try to console the node type export var renderTree = (node, setActiveNode, activeNode) => { console.log(node && node.type, 'look here'); Do you see node type? Commented Apr 23, 2018 at 13:53

2 Answers 2

2

You're probably running the source file in your browser instead of the built one.

Sign up to request clarification or add additional context in comments.

Comments

1

The variable node is undefined so doesn't have a property called type.

Change your check to

if(node && node.type === 'file'){
    ...
}

1 Comment

after applying your solution the error is gone, but the file tree doesn't appear in the browser, which is weird. @Stretch0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.