Giter Site home page Giter Site logo

Error using cards about nativebase HOT 22 CLOSED

geekyants avatar geekyants commented on May 4, 2024
Error using cards

from nativebase.

Comments (22)

bretth18 avatar bretth18 commented on May 4, 2024 2

Correct, the only issue i've ran into with NativeBase is the card component.

from nativebase.

sankhadeeproy007 avatar sankhadeeproy007 commented on May 4, 2024 1

Ignore the sad formatting.

from nativebase.

jingyao97 avatar jingyao97 commented on May 4, 2024 1

@bretth18 What are you using at the moment? I just started React Native not long ago :)

from nativebase.

himanshu-satija avatar himanshu-satija commented on May 4, 2024

<Card /> and <CardItem /> components are working fine with React Native v0.25.1 and Native Base v0.3.0.

It would be better if you upload the code you are having problem with.

from nativebase.

bretth18 avatar bretth18 commented on May 4, 2024

here's a trimmed version of the component:

import {Container, Header, Content, Footer, Title, Button, Icon, Card, CardItem } from 'native-base';
import ListComment from './ListComment';
import Firebase from 'firebase';

class YakView extends Component {

  render(){

    return(
      <Container>
          <Header>
            <Button transparent onPress={this._returnToYaks.bind(this)}>
                <Icon name="ios-arrow-left" />
            </Button>
              <Title>bison.</Title>
            <Button transparent>
                <Icon name="navicon"/>
            </Button>
          </Header>

          <Content>

            <View style={styles.container}>
              <Card cardBody={CardItem}>
                <CardItem>
                <Button transparent onPress={this.voteOnPost.bind(this)}>
                    <Icon name="ios-arrow-up"/>
                </Button>
                <Button transparent>
                    <Icon name="ios-arrow-down"/>
                </Button>
                <Text>{this.props.item.title}</Text>

                <Text>{this.props.item.time}</Text>
                <Text>{this.props.item.score}pts</Text>
               </CardItem>
              </Card>

// demo card, even this doesn't work              
              <Card>
                <CardItem>
                  <Text>Test</Text>
                </CardItem>
              </Card>

                <ListView
                  dataSource={this.state.dataSource}
                  renderRow={this._renderComment.bind(this)}
                  style={styles.listview}/>

                <Button info block  onPress={this._addComment.bind(this)}>
                    Add Comment
                </Button>

            </View>
         </Content>
      </Container>
    );
  }
}


module.exports = YakView;

from nativebase.

himanshu-satija avatar himanshu-satija commented on May 4, 2024

I tried your code without ListView and onPress props. It works fine. This might not be a NativeBase issue. Are you using a constructor in your class? If yes, did you call super(props) in your constructor?

Refer this SO question http://stackoverflow.com/questions/33376231/react-js-uncaught-error-invariant-violation

from nativebase.

bretth18 avatar bretth18 commented on May 4, 2024

I have a constructor in my class

  constructor(props){
    super(props);
    // sets our components state listener
    // firebase ref
    // console.log(this.props.item._key);
    this.state = {
      dataSource: new ListView.DataSource({
        // bizzare ass expression for handling rows
        rowHasChanged: (row1, row2) => row1 !== row2,
      })
    };
    var childKey = this.props.item._key.toString();
    console.log('CHILDKEY', childKey);
    this.commentRef = new Firebase('https://bisonyak.firebaseio.com/items/' + childKey);
  }

I'm not sure why the listview would be confilicting

Edit: For the record I've also tried adding a card in a component only displaying static text, and I encountered the same error.

from nativebase.

sankhadeeproy007 avatar sankhadeeproy007 commented on May 4, 2024

Hi, @bretth18 can you try the Card component independently? i.e. Just the Card component in a new page. No extra components. Might help us identify the problem if you still face an error.

from nativebase.

bretth18 avatar bretth18 commented on May 4, 2024

So if i do something like this:

  render(){
    return(
      <Container>

          <Content>
            <Card>
              <Text>Bison</Text>

              <Text>made by @bretth18</Text>
            </Card>


         </Content>



      </Container>
    );
  }

The component is rendering, but nothing is being shown and the styling of the card is non existent.
When cards contain no <CardItem> I'm still pretty sure the styling is wrong, they look like this:

simulator screen shot may 11 2016 7 01 13 am

from nativebase.

sankhadeeproy007 avatar sankhadeeproy007 commented on May 4, 2024

Okay, can you just try this out and get me a screenshot?
<Content padder> <Card > <CardItem> <Text>Nathaniel Clyne Cards have become widely used in recent years. They are a great way to contain and organize information, while also setting up predictable expectations for the user. </Text> </CardItem> </Card> </Content>

from nativebase.

bretth18 avatar bretth18 commented on May 4, 2024

Throws the same error:
simulator screen shot may 11 2016 7 19 16 am

from nativebase.

sankhadeeproy007 avatar sankhadeeproy007 commented on May 4, 2024

It's strange, the beahaviour you're getting.
`import {Container, InputGroup, Footer, Header, Input, Text, Button, Content, View, CheckBox, Title, Picker, Icon, List, CardItem, Thumbnail, Badge, Card} from 'native-base';
import React, {AppRegistry, Component, Switch} from 'react-native';

export default class UseCase extends Component {

render() {
    return (
        <Container> 
            <Header>                    
                <Button transparent  >
                    <Icon name={'ios-home'} />
                </Button>                    
                <Title>center</Title>
                <Button transparent  >
                    Back
                </Button>
            </Header>
            <Content padder>
               <Card >
                <CardItem>                        
                    <Text>Nathaniel Clyne Cards have become widely used in recent years. They are a great way to contain and organize information, while also setting up predictable expectations for the user.   </Text>
                </CardItem>
               </Card>
            </Content>
        </Container>
    )
}

}

`
Please try this out and let me know

from nativebase.

bretth18 avatar bretth18 commented on May 4, 2024

Just tried the code above, used the exact import list and I'm still getting the previous red screen of death error.

from nativebase.

sankhadeeproy007 avatar sankhadeeproy007 commented on May 4, 2024

Just to confirm, other than card, everything else is working okay?

from nativebase.

sankhadeeproy007 avatar sankhadeeproy007 commented on May 4, 2024

Closing due to inactivity.

from nativebase.

michaelnagy avatar michaelnagy commented on May 4, 2024

I'm getting the same error here, but with the

component, every time I try to add it, I get this same error. I just copied the example code you have on your documentation page and when trying to run this same error appears.

from nativebase.

sankhadeeproy007 avatar sankhadeeproy007 commented on May 4, 2024

@michaelnagy try to type in the example. Sometimes some blank characters get coped over as well.

from nativebase.

jingyao97 avatar jingyao97 commented on May 4, 2024

@bretth18 Can you try CardItem without any content (Text) in it ?

from nativebase.

bretth18 avatar bretth18 commented on May 4, 2024

@jingyao97 this issue is close to two years old, I abandoned using NativeBase long ago.

from nativebase.

SupriyaKalghatgi avatar SupriyaKalghatgi commented on May 4, 2024

@jingyao97 Share your use-case

from nativebase.

stardev24 avatar stardev24 commented on May 4, 2024

I also faced same problem.
But import {Image} from 'react-native' and use it inside CardItem
solved the problem.

from nativebase.

rfink avatar rfink commented on May 4, 2024

I'm encountering this issue as well.

from nativebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.