fix(sidebar): update type SidebarContext -> SidebarContextProps (#6926)

Hey, I noticed that the original code triggers the `ts/no-redeclare` ESLint error due to the naming conflict between the `SidebarContext` interface and the `SidebarContext` component.

![image](https://github.com/user-attachments/assets/33e6a8de-02bd-43a0-8279-beac8b051602)

I think `ts/no-redeclare` is a pretty common ESLint rule, I renamed the interface to `SidebarContextProps` to avoid the conflict. This naming style is consistent with the `carousel` component: (0f6efb9769/apps/v4/registry/new-york-v4/ui/carousel.tsx (L24)).

Hope this makes sense!
This commit is contained in:
t.yang
2025-03-14 20:53:22 +08:00
committed by GitHub
parent 0f6efb9769
commit a6e2d3672f
6 changed files with 15 additions and 15 deletions

View File

@@ -32,7 +32,7 @@ const SIDEBAR_WIDTH_MOBILE = "18rem"
const SIDEBAR_WIDTH_ICON = "3rem"
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
type SidebarContext = {
type SidebarContextProps = {
state: "expanded" | "collapsed"
open: boolean
setOpen: (open: boolean) => void
@@ -42,7 +42,7 @@ type SidebarContext = {
toggleSidebar: () => void
}
const SidebarContext = React.createContext<SidebarContext | null>(null)
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
function useSidebar() {
const context = React.useContext(SidebarContext)
@@ -113,7 +113,7 @@ function SidebarProvider({
// This makes it easier to style the sidebar with Tailwind classes.
const state = open ? "expanded" : "collapsed"
const contextValue = React.useMemo<SidebarContext>(
const contextValue = React.useMemo<SidebarContextProps>(
() => ({
state,
open,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -32,7 +32,7 @@ const SIDEBAR_WIDTH_MOBILE = "18rem"
const SIDEBAR_WIDTH_ICON = "3rem"
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
type SidebarContext = {
type SidebarContextProps = {
state: "expanded" | "collapsed"
open: boolean
setOpen: (open: boolean) => void
@@ -42,7 +42,7 @@ type SidebarContext = {
toggleSidebar: () => void
}
const SidebarContext = React.createContext<SidebarContext | null>(null)
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
function useSidebar() {
const context = React.useContext(SidebarContext)
@@ -122,7 +122,7 @@ const SidebarProvider = React.forwardRef<
// This makes it easier to style the sidebar with Tailwind classes.
const state = open ? "expanded" : "collapsed"
const contextValue = React.useMemo<SidebarContext>(
const contextValue = React.useMemo<SidebarContextProps>(
() => ({
state,
open,

View File

@@ -32,7 +32,7 @@ const SIDEBAR_WIDTH_MOBILE = "18rem"
const SIDEBAR_WIDTH_ICON = "3rem"
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
type SidebarContext = {
type SidebarContextProps = {
state: "expanded" | "collapsed"
open: boolean
setOpen: (open: boolean) => void
@@ -42,7 +42,7 @@ type SidebarContext = {
toggleSidebar: () => void
}
const SidebarContext = React.createContext<SidebarContext | null>(null)
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
function useSidebar() {
const context = React.useContext(SidebarContext)
@@ -122,7 +122,7 @@ const SidebarProvider = React.forwardRef<
// This makes it easier to style the sidebar with Tailwind classes.
const state = open ? "expanded" : "collapsed"
const contextValue = React.useMemo<SidebarContext>(
const contextValue = React.useMemo<SidebarContextProps>(
() => ({
state,
open,