Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown (and probably SyntaxHighlighter) default `children` value needs update #147

Closed
radekwlsk opened this issue Jan 18, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@radekwlsk
Copy link

commented Jan 18, 2018

With dcc 0.15.4 and:

The children property of dash_core_components.Markdown and dash_core_components.SyntaxHighlighter now accepts an array of strings (previously it had to be a string). Now, if an array is provided, it is collapsed into a string with line breaks (see #134).

now creating dcc.Markdown() component without any children value, for an empty component that will be later filled with a callback crashes in React constructor:

// must be a string or an array of strings
if(typeof props.children !== 'string') {
    props.children = props.children.join('\n');
}

as children is not a string, but the default children value that crashes on .join() call (at least that is what browser console tells me): TypeError: Cannot read property 'join' of null.

I think that the default value for dcc.Markdown.children should be "" or empty list.

Or if providing children value is required, then Python should catch components without it and raise an exception, as it is it was really hard to find the error.

@chriddyp

This comment has been minimized.

Copy link
Member

commented Jan 18, 2018

Yeah, that typeof isn't strict enough, it should just be if (R.type(props.children) === 'Array'). I'll fix this one.

@chriddyp

This comment has been minimized.

Copy link
Member

commented Jan 18, 2018

Thanks for reporting!

@chriddyp chriddyp closed this in ea97f72 Jan 18, 2018

@chriddyp chriddyp added the Type: Bug label Jan 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.