Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c719c6e

Browse filesBrowse files
committed
refactor(CToast): move the context outside the component
1 parent adc116d commit c719c6e
Copy full SHA for c719c6e

File tree

Expand file treeCollapse file tree

3 files changed

+12
-17
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-17
lines changed

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

Copy file name to clipboardExpand all lines: packages/coreui-react/src/components/toast/CToast.tsx
+3-15Lines 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

Copy file name to clipboardExpand all lines: packages/coreui-react/src/components/toast/CToastClose.tsx
+1-2Lines 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

+8Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.