Focus style for TextInput in react-native

后端 未结 7 1465
小鲜肉
小鲜肉 2020-12-05 17:56

In React Native, how do you change the style of a textInput when it gets focus? Say I have something like

class MyInput extends Component {
             


        
7条回答
  •  执念已碎
    2020-12-05 18:48

    You can create a state to keep track of the input-state and use that state to toggle the style. Here is a simple example

    const App = () => {
      const [isActive, setActive] = useState(false);
    
      return (
         setActive(true)} onBlur={() => setActive(false)}/>
      );
    }
    

提交回复
热议问题