-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
Refactor React components to fall more inline with existing React libraries #2733
Comments
Thanks @eagerestwolf, two things of note. First off, make sure you've read through this post. This outlines my availability, especially this week: Second, per this
This is a known issue and already on our radar to resolve. It was our first time packaging a Vite/React app for NPM and we mistakenly shipped more than just the components. I'm interested in learning more about the benefits of the syntactical changes you mentioned, but performance should be priority number one. We've made things work, now we make them work better. That's where I assumed we had the biggest issue and what I'd like to tackle first. As you mention, it's likely due to re-rendering and/or general memoization issues. My suggestion is we tackle each of the issues brought up above in individual dedicated PRs if possible. Handle it in "waves". That way we can keep changes small, surgical, and isolated. No rush if you wish to help contribute directly, especially given I'll be out for the next week, but I look forward to tackling these issues soon. |
Hey @eagerestwolf, first of all, thanks for the write up! I am one of the people that helped authoring the React components (Accordion and Progress). So any tips are genuinly much appreciated since I have no prior experience with React (apart from watching the occational Theo video). Also you stated:
I am the author of You also said:
I'm not sure I agree with this, I had learned that Like Chris said, I think opening a seperate issue and PR for each problem is best where we can deepdive into each problem in isolation. |
So, the syntactical changes (other than removing the return types) have literally no performance impact whatsoever. @Hugos68, I do apologize, I actually misspoke to some extent, I remembered like right before I went to sleep exactly what I was doing wrong when it comes to paths. You are correct in that Vite doesn't do anything with With that said, I guess my plan of action for the time being is to set up the path alias with both Vite and TypeScript (Vite for building, and TypeScript for development) and switch everything over to using the For anyone interested in what the React best practices look like, there are 3 important things to be familiar with:
|
Quick update per the audit items above - we've merged the following PR: This does two thigns:
Going forward we should ensure all work conforms to use these. |
Describe the feature in detail (code, mocks, or screenshots encouraged)
So, the time has come. I am going to open this issue as a place to track whats going on, and to communicate changes and whatnot before opening a full fledged pull request. I am by no means a React expert (though I follow one on YouTube lol), with that said the goal of this issue/pull request is going to be manyfold:
With that said, I have made one change already (that I feel is 100% necessary, fight me) and that is adding a path alias to the
tsconfig.json
for the./src/*
path (of course it's@/*
, fight me again). However, I do have a few proposed changes that need to be run by the Skeleton team before I implement them:jsx
fromreact-jsx
topreserve
you not only enable that consumer optimization I was referring to earlier, you also enable other frameworks (again, where other React imports aren't used). However, that comes with a major drawback. You cannot have the main React app that renders the React components within the React component library itself. Which brings me to my third point.function
declarations as opposed to arrow functions for TypeScript. As far as I know, on the JavaScript side, it's still mostly arrow functions, but who uses vanilla JS these days? From someone else who's been poking around the web development scene since Airbnb was popular, I get it, old habits are hard to break; but that's just what most people are doing these days. It's a personal preference, I'll do whatever the team wants. Both are literally the exact same thing under the hood.context.ts
file and imported.That's all I can think of at the moment, but I am working on the React rewrite as quickly as I can. As an example, here is what the Avatar component would look like before and after
BEFORE
AFTER
For a more complex example, here's a before and after of the AppBar component
BEFORE
AFTER
What type of pull request would this be?
Other
Provide relevant links or additional information.
Side note,
import React from 'react'
is no longer needed since I switched the project to using the new JSX Transform when ESLint and Prettier got taken out of the packages, so unless you are using the React namespace for something else, it doesn't need to be imported anymore.Also, I removed the
.js
extensions from the imports. It's not needed when using TypeScript, and everything works fine without it.Also also, I had to rollback the
tsconfig
paths for the react package. It broke the docs site. Apparently, Vite andvite-plugin-pagefind
do not play nicely withtsconfig
files.The text was updated successfully, but these errors were encountered: