-
Notifications
You must be signed in to change notification settings - Fork 937
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
ReactConfig lack of wildcard subdirectory search for adding components #526
Comments
Great idea! |
One of the issues with this is that some of the files may rely on other files being loaded in a particular order. In general it seems like a good idea, though! |
@Daniel15 This may be my lack of knowledge with regards to React or too simple an example but I went ahead and tested reordering my separated component scripts to this to try to mess up the dependencies, public static class ReactConfig
{
public static void Configure()
{
ReactSiteConfiguration.Configuration
.AddScript("~/ClientApp/Components/Comments/Comment.jsx")
.AddScript("~/ClientApp/Components/Comments/CommentForm.jsx")
.AddScript("~/ClientApp/Components/Comments/CommentList.jsx")
.AddScript("~/ClientApp/Components/Comments/CommentBox.jsx");
}
} (I'm following the reactjs.net tutorial and updated code libraries) Where CommentBox has a CommentForm and a CommentList and CommentList has several Comment components. This shouldn't work right since the order is reversed? I ran what I had and didn't notice any issues with the reordering. |
Execution might be deferred here until all the scripts have loaded. You could test this theory by doing something like this inside of render() {
let debugComponents = JSON.stringify([typeof CommentForm, typeof CommentList, typeof CommentBox]);
return <span>{debugComponents}</span>;
} Look at the server and client rendered output (you can disable script loading in your browser or use CURL to see just the server output). If you see undefined in the output at all, then the script ordering does matter. |
It's actually possible to provide a wildcard, at least for a flat directory (subdirectories have to be added manually), just that it's bugged on Windows due to conflicting directory separator between ASP.NET and Windows OS. I've submitted a fix in #631 |
Adding all of our components to be able to render them server side would eventually get out of hand. There should be a way to wildcard and search subdirectories.
Example of the problem
However this seems to be done effectively with the BabelBundle package that implements IncludeDirectory in this example. If this format could be mimicked in ReactSiteConfiguration.Configuration it should solve the issue.
Proposed Solution
The text was updated successfully, but these errors were encountered: