Redux
Treats wraps react-redux
and redux
together with @treats/redux
alias (with the exception of Provider
component that could be imported under @treats/component/Provider
see Components section. It is recommended to import from @treats/redux
instead of react-redux
or redux
directly because in the future, there might be improvements or patches that Treats made. Full documentation about react-redux
can be found here, Redux documentation can be found here.
import { connect } from "@treats/redux";
const MyPage = ({ username }) => (
<div>Hello {username}</div>
);
const mapStateToProps = state => ({
username: state.user.name
});
export default connect(mapStateToProps)(MyPage);