question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feedback on generated react code

See original GitHub issue

Following up on React feedback provided on #1494

Folders

One thing also I’ve seen that one folder is named “Master_Detail” in “frontEnd/src/components”. I also find this highly unusual since other folders in components folder are named with PascalCase (NavBar, WarningMessage). Usually React convention is PascalCase for component names and folder names as far as I’ve seen. I see that in a newly generated project that component is called MasterDetail, while in this example repo it’s called Master_Detail. Also, I’m not sure if word “master” currently clashes with the fact you are trying to rename master branch to something else (https://github.com/microsoft/WebTemplateStudio/issues/1475), so maybe even renaming “MasterDetail” component is something to keep in mind.

Files

One thing that comes to mind is the .jsx extension. I see that you are trying to follow Create React App as a baseline and they don’t use .jsx for newly generated project, they instead just use .js. Maybe you are in favor of .jsx because it’s more explicit that the file is a React component, but considering the fact that React components are usually named with PascalCase, that already gives them some distinction.

Regarding constants.js, maybe instead of defining the object and then adding items to it using dot(.) notation, why not just create objects and then add them to the constants object. Or even better yet, just make each of those keys a separate object without using the main CONSTANTS object.

CURRENT WORK

// Current implementation
const CONSTANTS = {};

CONSTANTS.ERROR_MESSAGE = {};
CONSTANTS.ERROR_MESSAGE.GRID_GET = "Request to get grid text failed:";
...

WITHOUT DOT NOTATION

const ERROR_MESSAGE = {
  GRID_GET: "Request to get grid text failed:",
  LIST_DELETE: "Request to delete list item failed:",
  ...
};

const CONSTANTS = {
  ERROR_MESSAGE,
};

WITHOUT CONSTANTS OBJECT

const ERROR_MESSAGE = {
  GRID_GET: "Request to get grid text failed:",
  LIST_DELETE: "Request to delete list item failed:",
  ...
};

const ENDPOINT = {
  GRID: "/api/grid",
  LIST: "/api/list",
  ...
};

Third solution seems best to me since you use the ERROR_MESSAGE or ENDPOINT object directly without having to do CONSTANTS.SOMETHING and the fact that variable names are all uppercase kinda suggests they are constants anyway. Even if my last proposed solution doesn’t seem great to you, I would highly suggest thinking about “without dot notation” suggestion. To me personally it seems easier that you can just take a quick look at an object and see all the key/value pairs it has, without having to go line by line below and seeing what key/value pairs were added line by line using dot notation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marko-hologramcommented, Oct 13, 2020

Hey, sorry I haven’t contributed more. I think I wanted to reply to this issue before, but then I just forgot about it.

Looks way better to me now and it looks more consistent.

@prupipho I’m glad you found my feedback valuable.

0reactions
prupiphocommented, Oct 13, 2020

Thanks one more time @marko-hologram for your feedback. The changes for this issue should be soon released.

Find below an example of the generated frontend code created for a react application Feel free to provide any more feedback.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Checklist for reviewing your own React code - Jakob Lind
Checklist for reviewing your own React code. Would you like an expert to review your React app to give you feedback and suggestions...
Read more >
React 2025 – Creating Feedback Pages - YouTube
Build and deploy a modern Jamstack application using the most popular open-source software. In this live stream, I cover:0:00 - Fetch ...
Read more >
Best Practices for Capturing User Feedback in React Native
Nothing beats getting real feedback from your users - but how should you go about capturing that feedback? In this tutorial we'll discuss ......
Read more >
Building a Custom User Reviews Page With Stars Rating in ...
In this tutorial, we created a custom user reviews page with stars rating from scratch. We also discussed the advantages of using React...
Read more >
How to use comments in React - Stack Overflow
// (double forward slash) is used to comment only a single line in React Native code, but it can only be used outside...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found