-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
registerComponent uses the component instance itself (#4865)
* Better registerComponent * Remove outdated test * Fix circular dependency * Added test for registerComponent * Remove commented code * Simplify test * Add test for external component * Remove unnecessary code line
- Loading branch information
Showing
11 changed files
with
250 additions
and
170 deletions.
There are no files selected for viewing
This file contains 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
30 changes: 30 additions & 0 deletions
30
editor/src/components/canvas/ui-jsx-canvas-renderer/component-renderer-component.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { PropertyControls } from 'utopia-api/core' | ||
import type { UTOPIA_INSTANCE_PATH, UTOPIA_PATH_KEY } from '../../../core/model/utopia-constants' | ||
import type { ElementPath } from '../../../core/shared/project-file-types' | ||
|
||
export type ComponentRendererComponent = React.ComponentType< | ||
React.PropsWithChildren<{ | ||
[UTOPIA_INSTANCE_PATH]: ElementPath | ||
[UTOPIA_PATH_KEY]?: string | ||
}> | ||
> & { | ||
topLevelElementName: string | null | ||
propertyControls?: PropertyControls | ||
utopiaType: 'UTOPIA_COMPONENT_RENDERER_COMPONENT' | ||
filePath: string | ||
originalName: string | null | ||
} | ||
|
||
export function isComponentRendererComponent( | ||
component: | ||
| ComponentRendererComponent | ||
| React.ComponentType<React.PropsWithChildren<unknown>> | ||
| null | ||
| undefined, | ||
): component is ComponentRendererComponent { | ||
return ( | ||
component != null && | ||
typeof component === 'function' && | ||
(component as ComponentRendererComponent).utopiaType === 'UTOPIA_COMPONENT_RENDERER_COMPONENT' | ||
) | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.