Mukesh Kumar Sharma
Mukesh Kumar Sharma

Reputation: 23

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

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.

Upvotes: 0

Views: 809

Answers (1)

cuongtd
cuongtd

Reputation: 3192

You can do like the following code

import heStyles from "./he";
import enStyles from "./en";

const styles = this.state.language = "he" ? heStyles : enStyles;

Upvotes: 1

Related Questions