I'm having a little problem with some vars.
My code is:
import React from 'react';
import mongoose from 'mongoose';
var sch = require('../models/schema');
export default class IndexPage extends React.Component {
render() {
sch.find(function(err,models){
//???
});
return (
<div className="home">
Afiez ceva {models}
</div>
);
}
}
How to achieve this? I ve tried all the posibilites. I want to be able to render someting like {models} or {models[0].whatever} .. Some tip please?
Reference for sch:
import mongoose from 'mongoose';
var schValue = new mongoose.Schema({
asd: String
});
schValue.set( 'collection', 'ecommerce' );
module.exports = mongoose.model('sch', schValue);
state. You should make a function that usessetState()and usethis.stateinside your render function. Once thestateupdates, your component will rerender automatically : facebook.github.io/react/docs/state-and-lifecycle.htmlmapover this list. and return thismapinside the render function.