Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

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

Closed
radekwlsk opened this issue Jan 18, 2018 · 2 comments
Labels
dash-type-bug Something isn't working as intended

Comments

@radekwlsk
Copy link

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
Copy link
Member

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

@chriddyp
Copy link
Member

Thanks for reporting!

@chriddyp chriddyp added the dash-type-bug Something isn't working as intended label Jan 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dash-type-bug Something isn't working as intended
Projects
None yet
Development

No branches or pull requests

2 participants