-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from etchteam/feature/wrap-776-right-side-of-…
…assignment-cannot-be-destructured Fix use of useAppState outside preact context
- Loading branch information
Showing
5 changed files
with
22 additions
and
24 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
import { ComponentChildren } from 'preact'; | ||
import register from 'preact-custom-element'; | ||
|
||
import { useAppState } from '@/lib/AppState'; | ||
import { CustomElement } from '@/types/customElement'; | ||
|
||
export default function MapSvg({ | ||
children, | ||
}: Readonly<{ children: ComponentChildren }>) { | ||
}: Readonly<{ children?: ComponentChildren }>) { | ||
const { publicPath } = useAppState(); | ||
const imgSrc = `${publicPath}images/map.svg`; | ||
|
||
return ( | ||
<> | ||
<img part="image" src={`${publicPath}images/map.svg`} alt="" /> | ||
<div part="content">{children}</div> | ||
</> | ||
<locator-map-svg> | ||
<img src={imgSrc} alt="" /> | ||
{children && ( | ||
<locator-map-svg-content>{children}</locator-map-svg-content> | ||
)} | ||
</locator-map-svg> | ||
); | ||
} | ||
|
||
register(MapSvg, 'locator-map-svg', [], { shadow: true }); | ||
|
||
declare module 'react' { | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
'locator-map-svg': CustomElement; | ||
'locator-map-svg-content': CustomElement; | ||
} | ||
} | ||
} |
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