8000 refactor(CToast): move the context outside the component · coreui/coreui-react@c719c6e · GitHub
[go: up one dir, main page]

Skip to content

Commit c719c6e

Browse files
committed
refactor(CToast): move the context outside the component
1 parent adc116d commit c719c6e

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

packages/coreui-react/src/components/toast/CToast.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import React, {
2-
createContext,
3-
forwardRef,
4-
HTMLAttributes,
5-
useEffect,
6-
useRef,
7-
useState,
8-
} from 'react'
1+
import React, { forwardRef, HTMLAttributes, useEffect, useRef, useState } from 'react'
92
import PropTypes from 'prop-types'
103
import classNames from 'classnames'
114
import { Transition } from 'react-transition-group'
125

6+
import { CToastContext } from './CToastContext'
7+
138
import { useForkedRef } from '../../hooks'
149
import { colorPropType } from '../../props'
1510
import type { Colors } from '../../types'
@@ -59,13 +54,6 @@ export interface CToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title
5954
visible?: boolean
6055
}
6156

62-
interface ContextProps extends CToastProps {
63-
visible?: boolean
64-
setVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>
65-
}
66-
67-
export const CToastContext = createContext({} as ContextProps)
68-
6957
export const CToast = forwardRef<HTMLDivElement, CToastProps>(
7058
(
7159
{

packages/coreui-react/src/components/toast/CToastClose.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import PropTypes from 'prop-types'
33

44
import { CButtonProps } from '../button/CButton'
55
import { CCloseButton, CCloseButtonProps } from '../close-button/CCloseButton'
6-
7-
import { CToastContext } from './CToast'
6+
import { CToastContext } from './CToastContext'
87

98
import { PolymorphicRefForwardingComponent } from '../../helpers'
109

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createContext } from 'react'
2+
3+
export interface CToastContextProps {
4+
visible?: boolean
5+
setVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>
6+
}
7+
8+
export const CToastContext = createContext({} as CToastContextProps)

0 commit comments

Comments
 (0)
0