export default class RegistroPersonas extends TrackerReact(React.Component) {
constructor(props) {
super(props);
this.state = {
subscription: {
pacientes: Meteor.subscribe(“pacientes”)
}
}
}
shouldComponentUpdate(nextProps, nextState) {
if (this.props === nextProps) {
return false;
}
}
componentWillUnmount() {
this.state.subscription.pacientes.stop();
}
data() {
return Pacientes.find({nombre : new RegExp(this.state.nombre, 'i')}).fetch();
}
render(){
let mario = this.data();
return(
<MuiThemeProvider >
<div>
<Grid>
<div className='segurosMedicos'>
<Row>
{mario.map((ob) => { return <PersonasRows key={ob.inx} objeto={ob} /> } ) }
</Row>
<DialogAgregarPersonas />
</div>
</Grid>
</div>
</MuiThemeProvider>
)
}
}
Good day,
I am trying to apply a filter on the data I return with the subscription when I apply a filter to this.state.nombre
return Pacientes.find({nombre : new RegExp(this.state.nombre, 'i')}).fetch(); <<
Does not update
Row>
{mario.map((ob) => { return <PersonasRows key={ob.inx} objeto={ob} /> } ) }
</Row>
if I force the rerender then the filter will get deleted if I add a new value to the Pacientes collection I will get a new Row but if I apply a filter it won't short the list if I apply the filter manually it works
return Pacientes.find({nombre : new RegExp(/j/i)}).fetch();
Any other way I could make react notice the change and update according to filter? the only way I think of.. it is making another component with the data I need and sending it a prop to force an update but seems like not the right way of doing it?
Help?? :blush: