我正在使用 React Native 表单输入字段,并想更改清除按钮的颜色和位置。默认清除按钮的颜色与我的背景颜色太接近。
<FloatingLabel
clearButtonMode={'always'}
style={styles.floatStyle}
inputStyle={styles.floatInput}
value={this.state.formData.email}
keyboardType={'email-address'}
autoCapitalize={'none'}
onChangeText={(value) => {
this.setState({
formData: {
...this.state.formData,
email: value
}
})
}}>Email</FloatingLabel>
Run Code Online (Sandbox Code Playgroud) 我想用来useEffect()检测状态值的变化,并使用作为道具接收的回调函数将该值传递给父组件。如果不禁用 eslint 缺少依赖项警告,我无法找到一种方法。我在子组件和那个孩子的孩子上都有这个问题。
这是父实现:
const updateValues = (newValues) => {
setValues({ ...values, ...newValues });
};
<GeneralUpdates onUpdate={updateValues} />
Run Code Online (Sandbox Code Playgroud)
这是第一个孩子(GeneralUpdates):
const [values, setValues] = useState({
name: '',
description: '',
});
// This handles form input changes
const handleChange = (prop) => (event) => {
setValues({ ...values, [prop]: event.target.value });
};
useEffect(() => {
onUpdate(values);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [values]);
<FilesUpload handleChange={onUpdate}/>
Run Code Online (Sandbox Code Playgroud)
这是孩子的孩子(文件上传):
const [featuredPhotos, setFeaturedPhotos] = useState([]);
useEffect(() => {
handleChange({ featuredPhotos });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [featuredPhotos]);
Run Code Online (Sandbox Code Playgroud)
添加 …
我在 React Native WebView 中嵌入了一个 YouTube 视频。我正在使用适用于Android的react-native-android-fullscreen-webview-video库,它在纵向和横向模式下都运行良好,但我需要在用户按下播放时将视频默认为全屏。
我为此尝试了其他库,包括 react-native-youtube,但每个库都会导致纵向或横向播放错误。
这是我的代码。一切正常,我只需要默认全屏播放。
<WebView source={{ uri: videoUrl }} />
Run Code Online (Sandbox Code Playgroud)