Skip to content

Commit

Permalink
feat: 뒤로 가기에 대한 webview goBack 브릿지 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ww8007 committed Aug 6, 2023
1 parent 2ad7719 commit 62ddc5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/common-ui/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { theme } from '@/styles/theme';
import { ReactNode } from 'react';
import getRem from '@/utils/getRem';
import { HEADER_Z_INDEX } from '@/constants/zIndex';
import useWebview from '@/common/service/hooks/useWebview';

interface HeaderProps {
showBackButton?: boolean;
Expand All @@ -19,8 +20,10 @@ const Header = ({
rightButton,
backButtonCallback,
}: HeaderProps) => {
const { postMessage } = useWebview();
const onClickBackButton = () => {
window.history.back();
postMessage('goBack');
backButtonCallback && backButtonCallback();
};
return (
Expand Down
8 changes: 7 additions & 1 deletion src/common-ui/Header/HeaderLeftAndRight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from '@emotion/styled';

import Icon from '../assets/Icon';
import Text from '../Text';
import useWebview from '@/common/service/hooks/useWebview';

export interface HeaderProps {
leftButton: {
Expand Down Expand Up @@ -31,11 +32,16 @@ const HeaderLeftAndRight = ({
middleText,
rightButton,
}: HeaderProps) => {
const { postMessage } = useWebview();
const onClickBackButton = () => {
leftButton.onClick();
postMessage('goBack');
};
return (
<StyleHeader>
<Left>
{leftButton.type === 'back' && (
<button onClick={leftButton.onClick}>
<button onClick={onClickBackButton}>
<Icon name="back" size="m" />
</button>
)}
Expand Down

1 comment on commit 62ddc5e

@vercel
Copy link

@vercel vercel bot commented on 62ddc5e Aug 6, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.