ThemeProvider error about Children
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react-native, typescript
- Lĩnh vực
- mobile
Hướng nghiên cứu
Start with the provided TSX entry code and reproduce the TypeScript warning when ThemeProvider receives the theme prop. Trace the ThemeProvider prop type definitions and verify that children is accepted in this usage; done means the reproduction type-checks without the reported error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is there an existing issue for this?
- I have searched the existing issues
Explain what you did
Issue https://github.com/react-native-elements/react-native-elements/issues/3452 is marked closed. I am starting a new project today and when I wrap theThemeProvider at the top level, I get a TS warning about the children.
I am just trying to get the dark mode toggle to work, so I am adding ThemeProvider
This error appears only after I add the theme prop. Without the theme prop, there is no error.
Expected behavior
ThemeProvider props have children as expected prop with or without the theme prop.
Describe the bug
When I include the theme prop only is when I see the bug:
Type '{ children: Element; theme: CreateThemeOptions; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Pick<Readonly, never> & InexactPartial<...> & InexactPartial<...>'.
Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Pick<Readonly, never> & InexactPartial<...> & InexactPartial<...>'.ts(2322)
Steps To Reproduce
this entry code:
import {
createTheme,
darkColors,
lightColors,
useThemeMode,
} from '@rneui/themed';
import { StatusBar } from 'expo-status-bar';
import React, { useState } from 'react';
import { Platform, View } from 'react-native';
import { ColorSchemeName, useColorScheme } from 'react-native-appearance';
import { ThemeProvider, useTheme } from 'react-native-elements';
import { SafeAreaProvider } from 'react-native-safe-area-context';
const theme = createTheme({
lightColors: {
...Platform.select({
default: lightColors.platform.android,
ios: lightColors.platform.ios,
}),
},
darkColors: {
...Platform.select({
default: darkColors.platform.android,
ios: darkColors.platform.ios,
}),
},
});
const ColorScheme = ({ children }) => {
const [mode, setMode] = useState<ColorSchemeName>();
const colorMode = useColorScheme();
const { theme } = useTheme();
React.useEffect(() => {
setMode(colorMode);
}, [colorMode]);
return (
<View
style={{ backgroundColor: theme.colors?.platform?.default as string }}
>
{children}
</View>
);
};
export default function App() {
console.log(theme);
return (
<SafeAreaProvider>
<ThemeProvider theme={theme}>
<ColorScheme>
<StatusBar style="auto" />
</ColorScheme>
</ThemeProvider>
</SafeAreaProvider>
);
}
### Screenshots
<img width="816" alt="image" src="https://github.com/react-native-elements/react-native-elements/assets/15162169/9a1e513e-9333-47b2-aa9b-796bb2072df0">
### Your Environment
<details>
<summary>`npx @rneui/envinfo`</summary>
```
React Native Elements Env Info
## Global Dependencies:
No related dependency found
## Local Dependencies:
- @rneui/base : ^0.0.0-edge.2
- @rneui/themed : ^0.0.0-edge.2
- expo : ~48.0.15
- react : 18.2.0
- react-native : 0.71.7
- react-native-elements : ^3.4.3 ```
</details>
- Ngôn ngữ chính
- MDX
- Star
- 25.9k
- Fork
- 4.7k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react-native-elements/react-native-elements
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
react-native-elements/react-native-elements#4035 · 1 bình luận ·
-
Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
react-native-elements/react-native-elements#3963 · 2 bình luận · 2 reaction ·
-
component: Button
react-native-elements/react-native-elements#4032 · 1 người được giao ·
-
TS Bug - @rneui/base@5.0.0 — Undeclared type dependency causes IconProps to lose color/name/size Đang mởcomponent: Icon
react-native-elements/react-native-elements#4027 · 2 bình luận · 4 reaction · 1 người được giao ·
-
📞 Needs Response from Author
react-native-elements/react-native-elements#4022 · 9 bình luận · 2 reaction · 1 người được giao ·
Tất cả issue của react-native-elements/react-native-elements
Issue tương tự
-
Build Failure: agora_rtc_engine compiled against android-31 while dependencies require android-34+ Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
avniproject/avni-client#2135 ·
-
react-doctor severity:warning tech-debt
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
digidem/comapeo-cloud-app#403 ·
-
Icon Requests Đang mởsupported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
LawnchairLauncher/lawnicons#4100 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
CypherBoxLLC/Cypher-Box#284 ·