fast-styles
fast-styles copied to clipboard
[Expo] Typescript error using useMode
Describe the bug
Typescript error using useMode();
To Reproduce Implementing the modes guide
import { ModeProvider, useMode } from "@fast-styles/react";
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import StyledView from "./StyledView";
export default function App() {
const [mode] = useMode();
return (
<ModeProvider>
<View style={styles.container}>
<Text>Open up App.tsx to start working on your app!</Text>
<StyledView mode={mode}>
<Text>Styled View</Text>
</StyledView>
<StatusBar style="auto" />
</View>
</ModeProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
Expected behavior Typescript errors should not happen
Environment "@fast-styles/babel-plugin": "^0.2.3", "@fast-styles/react": "^0.2.9", "expo": "~49.0.8", "expo-status-bar": "~1.6.0", "react": "18.2.0", "react-native": "0.72.4"
Currently, TypeScript infers the return of useMode by combining the types. I'm going to modify it to work with individual types based on position.
Using as const on the result might do the trick. Thank you.