refactor(react19): replace Context.Provider with Context value={}
- 升级 6 个文件的 Context 语法为 React 19 标准 - ThemeProviderContext, ChartContext, AnimationContext, TourContext, AssetStoreContext, RestartContext - 构建验证通过 - 功能完全等价
This commit is contained in:
@@ -50,5 +50,5 @@ export function AnimationProvider({
|
||||
setEnableWavesBackground,
|
||||
}
|
||||
|
||||
return <AnimationContext.Provider value={value}>{children}</AnimationContext.Provider>
|
||||
return <AnimationContext value={value}>{children}</AnimationContext>
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export function AssetStoreProvider({ children }: AssetStoreProviderProps) {
|
||||
}
|
||||
}, [])
|
||||
|
||||
return <AssetStoreContext.Provider value={value}>{children}</AssetStoreContext.Provider>
|
||||
return <AssetStoreContext value={value}>{children}</AssetStoreContext>
|
||||
}
|
||||
|
||||
export function useAssetStore() {
|
||||
|
||||
@@ -90,8 +90,8 @@ export function ThemeProvider({
|
||||
)
|
||||
|
||||
return (
|
||||
<ThemeProviderContext.Provider value={value}>
|
||||
<ThemeProviderContext value={value}>
|
||||
{children}
|
||||
</ThemeProviderContext.Provider>
|
||||
</ThemeProviderContext>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ export function TourProvider({ children }: { children: ReactNode }) {
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<TourContext.Provider
|
||||
<TourContext
|
||||
value={{
|
||||
state,
|
||||
tours,
|
||||
@@ -172,6 +172,6 @@ export function TourProvider({ children }: { children: ReactNode }) {
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</TourContext.Provider>
|
||||
</TourContext>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ const ChartContainer = React.forwardRef<
|
||||
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
|
||||
|
||||
return (
|
||||
<ChartContext.Provider value={{ config }}>
|
||||
<ChartContext value={{ config }}>
|
||||
<div
|
||||
data-chart={chartId}
|
||||
ref={ref}
|
||||
@@ -60,7 +60,7 @@ const ChartContainer = React.forwardRef<
|
||||
{children}
|
||||
</RechartsPrimitive.ResponsiveContainer>
|
||||
</div>
|
||||
</ChartContext.Provider>
|
||||
</ChartContext>
|
||||
)
|
||||
})
|
||||
ChartContainer.displayName = "Chart"
|
||||
|
||||
@@ -310,9 +310,9 @@ export function RestartProvider({
|
||||
}
|
||||
|
||||
return (
|
||||
<RestartContext.Provider value={contextValue}>
|
||||
<RestartContext value={contextValue}>
|
||||
{children}
|
||||
</RestartContext.Provider>
|
||||
</RestartContext>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user