Skip to content
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: props, states and contexts view #166

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pivanov
Copy link
Collaborator

@pivanov pivanov commented Dec 25, 2024

props-states-context.mov

Copy link

vercel bot commented Dec 25, 2024

@pivanov is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

pkg-pr-new bot commented Dec 25, 2024

Open in Stackblitz

npm i https://pkg.pr.new/aidenybai/react-scan@166

commit: fd38b48

const contextObj: Record<string, unknown> = {};

contexts.forEach((value, contextName) => {
contextObj[contextName] = value.displayValue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take note: in the future we might want to change this implementation, as this is a megamorphic code (hurts perf)

whatChangedSection: createHTMLTemplate<HTMLDetailsElement>(
`<details class="react-scan-what-changed" style="background-color:#b8860b;color:#ffff00;padding:5px">
<summary class="font-bold">What changed?</summary>
</details>`,
Copy link
Collaborator

@lxsmnsyc lxsmnsyc Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quotes and closing tags are optional, but this is fine. Although new lines and tabs/spaces, definitely we want to shave off.


const currentContext = getCurrentContext(fiber);
if (Object.keys(currentContext).length) {
tryOrElse(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the future, it should be of preference that we should use try-catch directly instead of using utilities like this (for 2 reasons: JS compilers cannot optimize this + closures are painful to optimize with). The utility itself has some ideal uses, but not in this case, I guess. Don't worry, I'll fix this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants