我正在尝试制作一个InputGroup具有两个图标或一个图标和一个按钮的图标。
应该使用一个图标来检查输入字段是否为空(使其正常工作)。另一个图标或按钮应用于将一些文本“注入”到该Input字段中。
目前我的代码如下所示:
import React, { Component } from 'react'
import { Content, List, InputGroup, Input, Icon, Button } from 'native-base'
export default class AddEquipment extends Component {
constructor(props) {
super(props)
this.state = {
parameters: {
one: {value:"", hint: "One"},
two: {value:"", hint: "Two"},
three: {value:"Valid", hint: "Three"}
}
}
this.updateParameter = this.updateParameter.bind(this)
this.validationStyle = this.validationStyle.bind(this)
}
componentDidMount() {
}
updateParameter(key, value) {
newState = {...this.state}
newState.parameters[key].value = value
this.setState = newState;
}
validationStyle(text) {
color …Run Code Online (Sandbox Code Playgroud) 我正在使用 NativeBase 中的 Picker 和 DeckSwiper,当我从 Picker 菜单中选择不同的主题时,它会更新 DeckSwiper 组件上的 dataSource 读取的状态,该状态应该重新渲染以显示新内容。目前仅在刷第一张卡时才会重新渲染。状态改变后如何重新渲染? 这是一个 GIF,展示了它当前的工作原理。
这是代码
const Item = Picker.Item;
const topics = [
{ label: "topic 1", value: "1" },
{ label: "topic 2", value: "2" },
{ label: "topic 3", value: "3" }
];
const cards = [
{ text: "Card A", topicId: "1", name: "One" },
{ text: "Card B", topicId: "2", name: "Two" },
{ text: "Card C", topicId: "3", name: "Three" },
{ text: "Card …Run Code Online (Sandbox Code Playgroud) 我需要删除我在图像中标记的边框。
我正在使用 react-native 和 native-base 标签。我需要删除选项卡的底部边框。
<Tabs>
<Tab heading="Tab1">
<Tab1 />
</Tab>
<Tab heading="Tab2">
<Tab2 />
</Tab>
<Tab heading="Tab3">
<Tab3 />
</Tab>
</Tabs>
Run Code Online (Sandbox Code Playgroud) 我正在使用 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) 我"native-base": "^2.12.1"在 react-native 项目中使用 nativebase ( )。我将在 react 组件类中的方法上使用 show toast
assignTicket(id) {
return Toast.show({
text: "Wrong password!",
buttonText: "Okay",
duration: 3000,
type: "success"
});
}
Run Code Online (Sandbox Code Playgroud)
但是在调用此方法时出现错误:
undefined 不是一个对象(评估'this.toastInstance._root')
我认为这不是 nativebase 版本问题,我使用的是最新版本。提前致谢。
我正在使用NativeBase和React Native。
NativeBase 按钮以这种方式创建:
<Button warning>
<Text>Hello</Text>
</Button>
Run Code Online (Sandbox Code Playgroud)
您可以使用不同的类型,例如info或success ,而不是警告。
现在,我想基于道具创建这些按钮并尝试执行以下操作:
<Button {this.props.type}>
<Text>Hello</Text>
</Button>
Run Code Online (Sandbox Code Playgroud)
但我找不到办法做到这一点,因为这个道具没有价值。
是否可以传递没有值的 props?
我在使用 nativebase 进行本地反应时面临一个问题。
<Content>
<List>
<ListItem>
<Left style={{ flex: 0 }}>
<Icon name="user" type="SimpleLineIcons"></Icon>
</Left>
<Body>
<Text> Profile </Text>
</Body>
<Right>
<Switch value={this.state.profile} />
</Right>
</ListItem>
....
</List>
</Content>
Run Code Online (Sandbox Code Playgroud)
当我更新状态(重新渲染组件)列表时,自动滚动到顶部/第一个:
this.setState({profile: true });
Run Code Online (Sandbox Code Playgroud)
如何防止自动滚动以获得更好的用户体验?
我在应用程序中使用原生基础 + 反应导航,需要更改应用程序的主题。一旦我更改主题,react-navigation 就会轻松更新,但问题是本机基本组件主题不会更改。对用户来说看起来很奇怪。
我曾使用此代码更改应用程序的主题
<StyleProvider style={getTheme(theme === 'LIGHT' ? platform : material)}>
<Container>
<NavigationContainer
theme={theme === 'LIGHT' ? DefaultTheme : MyThemeDark}>
<Stack.Navigator
initialRouteName={isProfile ? 'Root' : 'Selection'}>
..................
</Stack.Navigator>
</NavigationContainer>
</Container>
</StyleProvider>
Run Code Online (Sandbox Code Playgroud)
正如我所说,React 导航主题正在正确更新,但本机基本主题没有更新。
我正在将本机基础添加到我现有的 Expo React 项目中。我已经按照安装指南中的描述添加了必要的包,但是每次出现此错误时,我都会尝试多次迭代安装和卸载、删除节点模块并再次运行它,react-aria直接添加(包括只是@react-aria/interactions),但是然后添加每个包时我总是收到一个新错误。
大多数堆栈溢出帖子的建议似乎是“删除节点模块并重试”,但这对我没有任何影响。
我的package.json很简单:
"dependencies": {
"@react-native-community/masked-view": "0.1.10",
"@react-native-community/slider": "^3.0.3",
"@react-navigation/drawer": "^5.12.4",
"@react-navigation/native": "^5.9.3",
"@react-navigation/stack": "^5.14.3",
"expo": "~39.0.2",
"expo-ads-admob": "~8.3.0",
"expo-cli": "^4.2.1",
"expo-status-bar": "~1.0.2",
"firebase": "^7.9.0",
"mobx": "^6.1.7",
"mobx-react": "^7.1.0",
"native-base": "^3.1.0",
"prop-types": "^15.7.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.4.tar.gz",
"react-native-elements": "^3.2.0",
"react-native-gesture-handler": "~1.7.0",
"react-native-reanimated": "~1.13.0",
"react-native-safe-area-context": "^3.1.4",
"react-native-screens": "~2.10.1",
"react-native-svg": "12.1.0",
"react-native-vector-icons": "^8.1.0",
"react-native-web": "~0.13.12",
"styled-components": "^5.3.1",
"styled-system": "^5.1.5",
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/core": "~7.9.0",
"@expo/webpack-config": "^0.15.0",
"eslint": …Run Code Online (Sandbox Code Playgroud) 我正在使用 NativeBase.io 编写 React Native 应用程序
在我使用 NativeBase 的应用程序中,我收到以下错误......如何解决此问题?
这是错误:
警告 NativeBase:透明上深色文本的 1:1 对比度低于 WCAG 建议的绝对最小对比度 3:1。 https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast InputBase@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:193716:28 RCTView 查看@http://localhost:8081/ index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:150602:25 Box@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly =false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:191721:24 InputAdvance@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native。 example.DanceConnectyCube:193858:33 输入@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:193651:24 RCTView 查看@http //localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:150602:25 Box@http://localhost:8081/index.bundle? platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:191721:24 UserListScreen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app =org.reactjs.native.example.DanceConnectyCube:223372:50 StaticContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube: 234421:17 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:230142:24 SceneView@http://localhost: 8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:234305:22 RCTView视图 RCTView视图背景@http://localhost:8081/index.bundle?platform =ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:236500:21 Screen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app= org.reactjs.native.example.DanceConnectyCube:237782:108 RNSScreen AnimatedComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube: 67782:80 AnimatedComponentWrapper Screen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:238098:36 MaybeScreen@http://localhost :8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:237954:24 RNSScreenContainer ScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev= true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:238211:31 MaybeScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs .native.example.DanceConnectyCube:237923:23 RCTView 查看 SafeAreaProviderCompat@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:237712: 24 BottomTabView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:226059:30 @http://localhost:8081/index .bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:234075:24 BottomTabNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly= false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:225921:32 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example .DanceConnectyCube:230142:24 BaseNavigationContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:229651:28 ThemeProvider@http:// /localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:235690:21 NavigationContainerInner@http://localhost:8081/index.bundle?platform= ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:235550:26 SSRProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org .reactjs.native.example.DanceConnectyCube:193075:25 ToastProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:204142: 24 PortalProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:201313:50 HybridProvider@http://localhost:8081/ index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:214396:24 RNCSafeAreaProvider …
native-base ×10
react-native ×10
reactjs ×3
android ×2
expo ×1
list ×1
npm ×1
react-redux ×1
scrollview ×1
wcag ×1