-
Notifications
You must be signed in to change notification settings - Fork 61
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
Hidden and non-JS files in /src/components or /src/docs/examples cause "Cannot read property length of undefined" error #13
Comments
Correct, that's as designed. If you create a component folder without placing a component with the same name inside, then it will throw an error. I say it's by design because that's the way the project is intended to be used (though in retrospect, I could certainly have provided this helpful explanation when this issue occurs...) |
Thank you for the prompt reply. I'm getting an error in the I included a file with the same name... and here are samples of the files with the new/matching class names that successfully compile. index.js ProgressBarE.js import React from 'react';
class ProgressBarE extends React.Component {
// a component with a render statement that depends on
// two functions...
getColor = (percent) => {
...
}
getWidthAsPercentOfTotalWidth = () => {
return parseInt(this.props.width * (this.props.percent / 100), 10);
}
render() {
...
}
}
export default ProgressBarE; |
Can you share a fork of this repo that exhibits the issue? I can't reproduce this. |
Here you go: https://[email protected]:EdmundsEcho/ps-react.git Update: I figured it out. I had hidden files in the new directories that caused the function getFiles(filepath) {
return fs.readdirSync(filepath)
.filter(function(file) {
return fs.statSync(path.join(filepath, file)).isFile();
})
.filter(function(file) {
return ( !(/(^|\/)\.[^\/\.]/g).test(file))
})
;
} |
Interesting, thanks for sharing the solution. Out of curiosity, what were the hidden files? Just wondering if what happened to you could be a common issue... |
|
@EdmundsEcho @coryhouse The same thing happened to me yesterday, it took me some time debugging, and even tho I rejected idea of file .tern file causing the problem I was successfully recreated situation. Go in both folders component and examples and create the invisible file, or any file for that matter, and see it fail. It was very hard to find, as I wasn't sure what caused it because .tern wasn't creating its file when it wasn't triggered, and it needed to be in both directories. Anyway, after long hours debugging it's working now 👯, and as usual it one line of code. |
To clarify, this issue is caused by placing any non-js files in |
When I create a new component directory (with or without the accompanying docs directory), I generate an error after restarting the server.
I expect that after restarting the server, to see the new component listed in the docs page.
Instead I receive the following error.
I can restore the page by removing the new directory and restarting the server. I'm using the configuration files "as is" from this repo.
The text was updated successfully, but these errors were encountered: