Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styled component, eslint with react native gets "no-unused-vars"

'Text' is defined but never used  no-unused-vars

Here is the code section gets error

import {
  Text,
  StyleSheet,
} from 'react-native';
import color from './color';

export const Sub = styled.Text`
  color: ${color.secondary};
  font-size: 16;
  text-align: center;
  margin: 8px;

as we can see the Text has been consumed by Sub, since we don't want remove the no-unused-vars rule, we may need a plugin or setting to walk-around this


Thanks @Dan, you saved me from my tunnel vision

like image 230
Seeliang Avatar asked Oct 16 '22 20:10

Seeliang


1 Answers

Assuming that Text is a component, the documentation says that the correct way to declare it is:

export const Sub = styled(Text)`
  color: ${color.secondary};
  font-size: 16;
  text-align: center;
  margin: 8px;
`

It would also solve the eslint issue.

like image 101
Joao Ferreira Avatar answered Oct 21 '22 06:10

Joao Ferreira