Fix class component patching with tree patcher#118
Open
RedHatter wants to merge 1 commit intoSteamDeckHomebrew:mainfrom
Open
Fix class component patching with tree patcher#118RedHatter wants to merge 1 commit intoSteamDeckHomebrew:mainfrom
RedHatter wants to merge 1 commit intoSteamDeckHomebrew:mainfrom
Conversation
Contributor
Author
|
Included below is a snipit demonstrating tree patcher failing to patch a class component. routerHook.addPatch("/library/app/:appid", (props: { path: string; children: ReactElement }) => {
afterPatch(
props.children.props,
"renderFunc",
createReactTreePatcher(
[
(tree) => tree.props.children,
(tree) => tree.props.children?.[1]?.props.children.props.children.find((child: any) => "children" in child.props).props.children,
],
(_: Array<Record<string, unknown>>, tree?: ReactElement) => {
return tree
}
),
)
return props
})This causes a crash with the error message |
Member
|
Very interesting, ill test this as soon as I have a chance Probably an oversight I made as all of the patcher was probably made at like 3 am sleep deprived |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The new tree patch expects the
node.typeof class components to be of type "object" however this is not the case.An example class component node might look like
Where
node.typeis a component class. Since classes in javascript are of type "function"the tree patcher fails to detect and wrap the class component.
An alternative fix could be to remove the switch and test the prototype first