-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React component lifecycle issue #41
Comments
I don't quite understand your situation. Could you please share more details? |
Sure. I'll show you a code example of what I'm trying to do: //TaskStore.js
State.modify('tasks', () => {
return Tasks.find().fetch()
})
// TaskListComponent.js
TaskList = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
return {
tasks: State.get('tasks')
}
},
render() {
return (
<ul>
{
this.data.tasks.map(t => {
return <Task task={t} />
})
}
</ul>
)
}
})
//TaskComponent.js
Task = React.createClass({
componentWillUpdate(nextProps, nextState) {
// this.props.task should be the previous props object
},
render() {
return (
<li>{this.props.task.name}</li>
)
}
}) If you look in the The problem I'm having is that Hope this helps? |
I see. So if you do getMeteorData() {
return {
tasks: Tasks.find().fetch()
}
}, does it work? |
That seems to work. Is this the way I should be doing it? |
Not really. I just want to know if the problem is with ReactiveState or not. What if you do this?
then: // TaskListComponent.js
var state = ReactiveDict('state');
Tracker.autorun(function() {
var tasks = Tasks.find().fetch();
state.set('tasks', tasks);
});
TaskList = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
return {
tasks: state.get('tasks')
}
},
... // everything like the one you posted |
i ran into the same issue. shouldComponentUpdate has already the new props:
and in ActionsMenu:
|
When using
componentWillUpdate(nextProps, nextState)
, this.props is already set to the nextProps value.According to this page: https://react-in-meteor.readthedocs.org/en/latest/meteor-data/
this.props
should only be updated after that function is called. It actually seems to update before any of the functions listed on that page have been invoked.Is there possibly another function I need to call when using MeteorFlux?
The text was updated successfully, but these errors were encountered: