Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native React本地纸张复选框设计不起作用,不可见,涟漪效应起作用_React Native_React Native Paper - Fatal编程技术网

React native React本地纸张复选框设计不起作用,不可见,涟漪效应起作用

React native React本地纸张复选框设计不起作用,不可见,涟漪效应起作用,react-native,react-native-paper,React Native,React Native Paper,我有以下代码: <Checkbox.Android color={`#FA4616`} uncheckedColor={`#FA4616`} status={'checked'} onPress={() => {}} /> {} /> 我看到的只是不可见复选框,尝试删除颜色,也没有显示,尝试删除。Android,仍然没有显示 react native paper package works的所有其他模块,甚至单选按钮,我是否遗漏了什么,组件的完整代码

我有以下代码:

<Checkbox.Android
    color={`#FA4616`} uncheckedColor={`#FA4616`}
    status={'checked'}
    onPress={() => {}}
/>
{}
/>
我看到的只是不可见复选框,尝试删除颜色,也没有显示,尝试删除。Android,仍然没有显示

react native paper package works的所有其他模块,甚至单选按钮,我是否遗漏了什么,组件的完整代码如下所示

尝试了一切,甚至在提供者中包装了组件,尝试了删除门户,加载了主题,因为父组件是设计好的,但复选框也不会出现在父组件中,只是复选框应该出现的涟漪效应

import React, {Component} from "react";
import PropTypes from "prop-types";
import {Card, Checkbox, Dialog, Modal, Portal, Provider, Text} from 'react-native-paper';
import {OutlinedInput} from '../../native/components/UI/OutlineInput';
import {View} from 'native-base';

export default class SelectModal extends Component {
    static propTypes = {
        save: PropTypes.func.isRequired,
        hideModal: PropTypes.func.isRequired,
        data: PropTypes.array.isRequired,
        title: PropTypes.string.isRequired
    };

    static defaultProps = {
        data: [],
        title: ''
    };

    handleChange = (name, { target: { value, checked }}) => {
        const options = this.state[name];
        let index;

        if (checked) {
            options.push(+value)
        } else {
            index = options.indexOf(+value);
            options.splice(index, 1)
        }

        this.setState({[name]: options})
    }

    constructor(props) {
        super(props);

        this.state = {
            selectedChoices: [],
            filtered: this.props.data
        }
    }

    save = () => {
        this.props.save({
            selectedChoices: this.state.selectedChoices
        })
    }

    cancel = () => {
        this.props.hideModal();
    }

    search = (value) => {
        let currentList = [];
        let newList = [];
        if (value !== "") {
            currentList = this.props.data;
            newList = currentList.filter(item => {
                const lc = item.name.toLowerCase();
                const filter = value.toLowerCase();
                return lc.includes(filter);
            });
        } else {
            newList = this.props.data;
        }

        this.setState({
            filtered: newList
        });
    }

    componentDidMount() {
        this.setState({
            selectedChoices: this.props.selectedData
        });
    }

    render() {
        return (
            <Portal>
                <Modal visible={true} onDismiss={this.cancel()}>
                    {/*<Dialog.Title style={{ fontSize: 10 }}>{ this.props.title }</Dialog.Title>*/}
                    {/*<Dialog.Content>*/}
                    <Card>
                        <Card.Content>
                            <OutlinedInput onChangeText={(text) => { this.search(text) }} placeholder="Otsi" className={`mb-4`} />

                            { this.state.filtered.map((rs) => (
                                <View style={{ flexDirection: 'row' }} key={rs.id}>
                                    <Checkbox.Android
                                        color={`#FA4616`} uncheckedColor={`#FA4616`}
                                        status={'checked'}
                                        onPress={() => {
                                        }}
                                    />
                                    <Text style={{marginTop: 5}}> { rs.name }</Text>
                                </View>
                            ))}
                        </Card.Content>
                    </Card>
                    {/*</Dialog.Content>*/}
                    {/*<Dialog.Actions>*/}
                    {/*    <ContainedButton onPress={(e) => {this.save(e)}}>*/}
                    {/*        salvesta*/}
                    {/*    </ContainedButton>*/}
                    {/*</Dialog.Actions>*/}
                </Modal>
            </Portal>
        );
    }
}
import React,{Component}来自“React”;
从“道具类型”导入道具类型;
从“react native paper”导入{卡片、复选框、对话框、模式、门户、提供者、文本};
从“../../native/components/UI/OutlineInput”导入{OutlinedInput};
从“本机基”导入{View};
导出默认类SelectModal扩展组件{
静态类型={
保存:需要PropTypes.func.isRequired,
hideModal:PropTypes.func.isRequired,
数据:需要PropTypes.array.isRequired,
标题:PropTypes.string.isRequired
};
静态defaultProps={
数据:[],
标题:“”
};
handleChange=(名称,{target:{value,checked}})=>{
const options=this.state[name];
let指数;
如果(选中){
选项。推送(+值)
}否则{
索引=选项。indexOf(+值);
选项.拼接(索引,1)
}
this.setState({[name]:options})
}
建造师(道具){
超级(道具);
此.state={
selectedChoices:[],
过滤:this.props.data
}
}
保存=()=>{
这是道具({
selectedChoices:this.state.selectedChoices
})
}
取消=()=>{
this.props.hideModal();
}
搜索=(值)=>{
让currentList=[];
让newList=[];
如果(值!==“”){
currentList=this.props.data;
newList=currentList.filter(项=>{
const lc=item.name.toLowerCase();
const filter=value.toLowerCase();
返回信用证。包括(过滤器);
});
}否则{
newList=this.props.data;
}
这是我的国家({
过滤:新列表
});
}
componentDidMount(){
这是我的国家({
selectedChoices:this.props.selectedData
});
}
render(){
返回(
{/*{this.props.title}*/}
{/**/}
{this.search(text)}placeholder=“Otsi”className={`mb-4`}/>
{this.state.filtered.map((rs)=>(
{
}}
/>
{rs.name}
))}
{/**/}
{/**/}
{/*{this.save(e)}>*/}
{/*萨尔维斯塔*/}
{/*    */}
{/**/}
);
}
}

在我的例子中,发生这种情况是因为我的项目缺少本机向量图标依赖项。react本地文档中提到了它。 您将不得不使用安装它;

如果它已经安装,请尝试通过转到项目目录>打开cmd>运行npx react本机链接react本机向量图标或 反应本机链接反应本机矢量图标以适应您的设置

cmd将显示链接成功


现在再次运行你的应用程序…

你应该使用Android的平台指南。如果你想在整个应用程序中运行Andoird平台指南,请选中Android。否则,您可以使用Checkbox.IOS,您将在整个应用程序中获得IOS平台指南复选框