所以我最近刚刚迁移到 WSL2。我在 WSL1 上使用的所有工具现在都损坏了。
命令如下:
$ expo start
$ npm start
Run Code Online (Sandbox Code Playgroud)
在 IP 地址上运行应用程序172.--.---.---
这会破坏我使用的许多仍在运行的工具192.---.--.-
上面的图片与我收到的错误不准确。但如图所示,我无法使用手机上配置的端口以外的端口访问 Expo 项目。
有没有办法将我的 WSL2 子系统的 IP 更改为主机的 IP,以便我可以从手机连接到我的 Expo 项目?
我刚刚将我的 Javascript React Native 项目切换到 Typescript 项目,但是当我更改它时,在插入函数时出现很多错误StyleSheet()
以前我曾经这样做过:
const Header = ({ someBoolean }) => (
<View style={styles.conditionalStyle(someBoolean)}>
<Text></Text>
</View>
);
const styles = StyleSheet.create({
conditionalStyle: (someBoolean) => ({
marginTop: someBoolean ? 20 : 5
})
});
Run Code Online (Sandbox Code Playgroud)
但是当我切换到打字稿时,它开始抛出这些错误:
Type `
(absolute: any) => {
height: number;
width: number;
display: string;
flexDirection: string;
borderBottomLeftRadius: number;
borderBottomRightRadius: number;
position: string;
zIndex: number;
}` is not assignable to type `ViewStyle | TextStyle | ImageStyle` ts(2322)
Header.tsx(81, 3):
The expected type comes from …Run Code Online (Sandbox Code Playgroud) 我需要为数组中的每一项渲染一个 jsx 组件。
import { ListView } from './components'; // Custom component
const array = ["item1","item2","item3"];
export default function App() {
return(
<div>
{/* Here i want to render a <ListView /> component for each of the items in the array. */}
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
这里数组中有 3 个项目,所以我想渲染 3 个不同的组件。
任何帮助将不胜感激。