Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(site): fix react state violation in filetree create/update utils#20483

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DanielleMaywood merged 4 commits intomainfromdanielle/site/react-state-violation
Oct 28, 2025

Conversation

@DanielleMaywood
Copy link
Contributor

@DanielleMaywoodDanielleMaywood commentedOct 26, 2025
edited
Loading

Closes#20482

Ensure file tree utils don't modify their parameters so we don't violate Reacts rules

Closes#20482I've just replaced `set` from `lodash` with `set` from `lodash/fp`. Wecould alternatively just ensure `fileTree` is cloned before using themutable version.
@DanielleMaywoodDanielleMaywood changed the titlefix(site): react state violation in filetree create/update utilsfix(site): fix react state violation in filetree create/update utilsOct 26, 2025
@DanielleMaywoodDanielleMaywood marked this pull request as ready for reviewOctober 26, 2025 22:31
Copy link
Contributor

@BrunoQuaresmaBrunoQuaresma left a comment

Choose a reason for hiding this comment

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

That is interesting. Could we create a test for that? To make sure we don't have any regressions in the future?

Copy link
Contributor

@ParkreinerParkreiner left a comment

Choose a reason for hiding this comment

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

The change itself is right – I'm just worried about what the style of change means for the larger codebase

}

returnset(fileTree,path.split("/"),value);
returnset(path.split("/"),value)(fileTree);
Copy link
Contributor

@ParkreinerParkreinerOct 27, 2025
edited
Loading

Choose a reason for hiding this comment

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

I get the benefits of opting for the FP version, especially since it handles immutability out of the box, but I'm worried about bringing new conventions into the codebase without having any conversations about them first

The rest of the codebase leans into a lot more vanilla JS-based patterns, and while currying like this works just fine, I'm worried about consistency

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be leaning towards making a copy of the value using traditional JS methods, and then using the vanilla Lodashset method on that

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah I'm more than happy to do that 👍

- Replace use of `lodash/fp/set` with `lodash/cloneDeep` followed by`lodash/set`.- Fix `removeFile` as that still did mutation.- Update tests to assert that the original FileTree was not modified.
@DanielleMaywood
Copy link
ContributorAuthor

@BrunoQuaresma I've added a test to verify thecreateFile,updateFile, andremoveFile functions to not modify the incomingFileTree.

@Parkreiner I've replaced the usage oflodash/fp/set withlodash/cloneDeep andlodash/set. Plus fixed a flawed shallow clone in theremoveFile function.

@DanielleMaywoodDanielleMaywood merged commit40fc337 intomainOct 28, 2025
33 checks passed
@DanielleMaywoodDanielleMaywood deleted the danielle/site/react-state-violation branchOctober 28, 2025 21:41
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 28, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@aslilacaslilacaslilac approved these changes

+2 more reviewers

@BrunoQuaresmaBrunoQuaresmaBrunoQuaresma left review comments

@ParkreinerParkreinerParkreiner left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

@DanielleMaywoodDanielleMaywood

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Unable to create new file in template editor in react development mode

5 participants

@DanielleMaywood@aslilac@BrunoQuaresma@Parkreiner

[8]ページ先頭

©2009-2025 Movatter.jp