How can I use state
properties from react-redux
to specify the data that is injected by react-meteor-data
?
The structure of the react
component is as follows:
import React from "react";
import {createContainer} from "meteor/react-meteor-data";
import {connet} from "react-redux";
import {Data} from "./data.js"
class App extends React.Component {
render() {
return (
<div>
{JSON.stringify(this.props.profile)}
</div>
);
}
}
const mapStateToProps = state => ({
ID: state.dataId // ID gets assigned to props here
});
export default createContainer(
() => ({
profile: Data.findOne({_id: >>>ID<<<}) // ID is needed here
}),
connect(mapStateToProps)(App)
);
Many thanks!
You should take a look at React-Komposer, it has functionality for redux as well as meteor trackers.
https://github.com/kadirahq/react-komposer
with komposer you will get two params props
and onData
props
are the props passed to your container and onData
is the new props to be sent to the composed component.
Now for connecting both of the systems together, I'm not positive this will work or is the best solution but I'm thinking you could do something like this
connect(mapStateToProps)(composeWithTacker(onPropsChange)(App))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With