[英]how can I import multiple CSS files conditionally based on this.state data in react native
I need to import multiple css files conditionally in react native project like 我需要在React Native项目中有条件地导入多个CSS文件
import React, { Component } from "react";
if(this.state.language = "he"){
import styles from "./he";
}else{
import styles from "./en";
}
But it's not working. 但这不起作用。 I need to add 2 different CSS for LTR and RTL based on language.
我需要根据语言为LTR和RTL添加2种不同的CSS。
You can do like the following code 你可以像下面的代码一样
import heStyles from "./he";
import enStyles from "./en";
const styles = this.state.language = "he" ? heStyles : enStyles;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.