Giter VIP home page Giter VIP logo

reactnativenews's Introduction

ReactNativeNews

a news app code by react native

install react native

check the follow link to make sure you have already installed react native :

http://facebook.github.io/react-native/docs/getting-started.html

install

cd ~/reace-native/
git clone https://github.com/tabalt/ReactNativeNews.git
cd ReactNativeNews
npm install

demo

reactnativenews's People

Contributors

tabalt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reactnativenews's Issues

This is my file i am facing error

this my error
VM691:1 Warning: Cannot update during an existing state transition (such as within render or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to componentWillMount.

Actually i am facing error in this.setState()

class TemplateTab extends React.Component {
constructor(props) {
super(props);
this.state = {
tabName: "",
key: this.props.activeKey,
searchData: "",
getDetails: "",
onchangeEmailIntegraionValue: "",
userId: "",
popoverDate: "",
modalSize: "",
integrationModalTitle: "",
integrationComponent: "",
savaBtnTxt: "",
CancelBtnText: "",
modalTitle: "",
dynamicParentClass: "",
modalClass: "",
showModal: "",
close: "",
closeBtnTxt: "",
saveBtnTxt: "",
save: "",
title: "",
fname: "",
editOrAdd: "",
tabId: "",
newkey: "0",
canId: "",
tab: this.props.tab,
SearchValue: "",
searchError: false,
SearchErrorMsg: "",
tabSearch: this.props.tabSearch,
startIndex: 0,
ToggleShow: "",
EmailDetails: {
startIndex: 0,
maxIndex: 20,
pageIndex: 0,
candidateState: "new_candidates",
status: false,
titleCount: 0,
carry: 0,
countState: true,
followUpDate:"",
skills: "",
title: "",
experience: "",
education: "",
location: "",
adminCandidateCilentSubmission: "",
adminCandidateStatus: "",
recruiterOwnedBy: "",
availability: "",
jobSearchStatus: "",
lastTitle: "",
lastLocation: "",
recruiterNotes: "",
subscriptions: "",
lastActivity: "",
loginTime: "",
requestStatus: ""
},
disabled: false,
clearSelected: false,
searchforCandidate: false,
WinWidth: window.innerWidth,
sendStatus: "",
campaignStatus:false,
btnName:"Create List",
templateType:"plainEmail",
operation:"",
optionsChecked:[],
subTabActiveKey:0,
userRemoveBtnLoading:false,
userRemoveModal:false,
subTabActiveName:'all'
};
}

getCanId = canId => {
let dis_status = this.props.clikedId ? this.props.clikedId: "";
if (this.props.activeKey === 2 && (this.props.subTabKey === 0 || this.props.subTabKey === 4 || this.props.subTabKey === 5 || this.props.subTabKey === 6) ) {
let AdminCandidate = { newUserListId: canId };
this.setState ({
disabled: dis_status.length != 0 ? false : true,
canId: canId,
AdminCandidate
});
}
console.log("res",canId)

Error when I push to details route

I'm not sure why i get this - but everytime when i attempt to push the rowData (news piece object) to the details component I get an infinite amount of errors stating "cannot update during an existing state transition" as shown below:

screen shot 2015-12-14 at 8 23 24 am

Here's my code:

var React = require('react-native');
var {
    View, 
    Image,
    StyleSheet,
    Text, 
    ScrollView, 
    ActivityIndicatorIOS, 
    ListView, 
    TouchableHighlight, 
} = React;

//additional libraries
var Parse = require('parse/react-native');
//var Reflux = require('reflux');

//dynamic component references
var ArticlePreview = require('./exp_base_components/article-preview');
var Api = require('../utils/api');
var FeedStore = require('../stores/feed-store');
var ArticleDetails = require('./exp_base_components/article-details');
var Spinner = require('react-native-spinkit');
//var Actions = require('../../actions');

//dimensions
var Dimensions = require('Dimensions');
var window = Dimensions.get('window');

module.exports = React.createClass({ 
    componentWillMount: function() {
        Parse.User.currentAsync()
            .then((user) => { this.setState({user: user}); })
    },  
    getInitialState: function() {

        var getSectionData = (dataBlob, sectionID) => {
            //console.log("SectionID GIS, getSectionData: " + sectionID);
            return dataBlob[sectionID];
        }

        var getRowData = (dataBlob, sectionID, rowID) => {
            //console.log("RowID GIS, getRowData: " + rowID);
            return dataBlob[sectionID + ':' + rowID];
        }

        return {
            user: null, 
            isLoaded: false, 
            dataSource : new ListView.DataSource({
                getSectionData          : getSectionData,
                getRowData              : getRowData,
                rowHasChanged           : (row1, row2) => row1 !== row2,
                sectionHeaderHasChanged : (s1, s2) => s1 !== s2
            }), 
        }
    },
    componentDidMount: function() {
        //console.log(this.state.user);
        var personalFeed = null; 
        var Onboarding = Parse.Object.extend("Onboarding");
        var query = new Parse.Query(Onboarding);
        query.equalTo("userObjectId", Parse.User.current());
        var that = this;
        query.find({
          success: function(result) {
            console.log("Successfully retrieved " + result.length + " users!");
            var object = result[0];
            console.log(object.id);
            // Do something with the returned Parse.Object values
            console.log(object.get('interests'));
            that.organizeData(object.get('interests')); 
          },
          error: function(error) {
            console.log("Error: " + error.code + " " + error.message);
          }
        });

    },
    organizeData: function(personalFeed) {
        var data_store = null; 
        //get the latest articles on page load
        //this will pre-fill out articles state 
        FeedStore.getArticles(personalFeed)
            .then((data) => {

                console.log("================");
                console.log("data is at home");
                console.log(data);
                console.log("================");


                var entries = data, 
                length = entries.length,
                dataBlob = {},
                sectionIDs = [],
                rowIDs = [],
                entry,
                sectionID, 
                rowID, 
                i; 

                console.log(entries.length);
                for (i = 0; i < length; i++)
                {
                    entry = entries[i]; 
                    //console.log(entry);

                    //add section/row to section id array

                    //mapping section id array for section data 
                    sectionID = entry.title.replace(/\s+/g, '').toLowerCase() + i; 
                    //console.log("SectionID = " + sectionID);
                    sectionIDs.push(sectionID);
                    dataBlob[sectionID] = entry.title; 

                    //mapping row id array for row data 
                    rowIDs[i] = []
                    rowID = sectionID;
                    // console.log("RowID = " + rowID); 
                    rowIDs[i].push(rowID);
                    dataBlob[sectionID + ':' + rowID] = entry; 
                }

                //console.log(dataBlob);

                this.setState({
                    dataSource : this.state.dataSource.cloneWithRowsAndSections(dataBlob, sectionIDs, rowIDs),
                    isLoaded   : true, 
                });

            }).done();
    }, 
    render: function() {

        if (!this.state.isLoaded) {
            return this.renderLoadingView();
        }

        return this.renderListView();
    }, 
    renderLoadingView: function() {
        /*<ActivityIndicatorIOS
                    animating={!this.state.isLoaded}
                    style={[styles.activityIndicator, {height: 80}]}
                    size="large" />*/
        return (
            <View style={styles.container}>
                <Spinner style={styles.spinner} isVisible={!this.state.isLoaded} size={50} type={'Arc'} color={'#FF0000'}/>
            </View>
        );
    }, 
    renderListView: function() {
        return (
            <View style={styles.container}>
                <ListView
                    dataSource = {this.state.dataSource}
                    initialListSize = {5}
                    pageSize={5}
                    renderRow  = {this.renderRow} />
            </View>
        );
    }, 
    renderRow: function (rowData, sectionID, rowID) {
        /* TEST
        console.log("Getting my rows on");
        console.log(rowID);*/
        //console.log(rowData);

        //call to api to get articles from rss/api var Articles 

        //check for images 
        if (typeof rowData.mediaGroups === 'undefined')
        {
            return <ArticlePreview
                category={rowData.categories[0]}
                key={sectionID}
                heartText={'2.9k'}
                categoryPress={this.onCategoryDetailsPress}
                selected={false}
                source={require('../img/stock_image.png')}
                text={rowData.title.toLowerCase().replace('&nbsp;','')}
                onPress={this.onArticleDetailsPress(rowData)} />
        } else 
        { 
            var url = rowData.mediaGroups[0].contents[0].url; 
            if (url.indexOf('w=150') > -1)
            {
                url.replace("w=150", "w=500");
            }
            var catsource = rowData.categories[0]; 
            if (typeof catsource == "undefined")
            {
                catsource = "News";
            }
            return <ArticlePreview
                category={catsource}
                key={sectionID}
                heartText={'2.9k'}
                categoryPress={this.onCategoryDetailsPress}
                selected={false}
                source={{uri: url }}
                text={rowData.title.toLowerCase().replace('&nbsp;','')}
                onPress={this.onArticleDetailsPress(rowData)} />
        }

    },
    onCategoryDetailsPress: function() {
        //forward to sytled web view of categorical article feed
        console.log("onCategoryDetailsPress"); 
    }, 
    onArticleDetailsPress: function(entry) {
        //forward to sytled web view of article details given link
        console.log("onArticleDetailsPress"); 
        this.props.navigator.push({
            name: 'articledetails', 
            passProps: {
                entry: entry
            }
        });
    }, 
    /*
    onChange: function(event, articles) {
        this.setState({articles: articles}); //trigers re-render of component
    }
    */

});


styles = StyleSheet.create({
    container: {
        flex: 1, 
        alignItems: 'center', 
        justifyContent: 'center',
        backgroundColor: '#000000', 
    }, 
    activityIndicator: {
        alignItems: 'center',
        justifyContent: 'center',
    },
    spinner: {
        marginBottom: 50,
    },
});

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.