Redux store is not a singleton anymore (-> bug fixes)

This commit is contained in:
riggraz
2019-09-14 12:42:30 +02:00
parent 7f49b14c06
commit dcdb99401f
7 changed files with 98 additions and 43 deletions

View File

@@ -1,23 +1,53 @@
import * as React from 'react';
import { Provider } from 'react-redux';
import store from '../../stores';
import createStoreHelper from '../../helpers/createStore';
import Post from '../../containers/Post';
import IPostStatus from '../../interfaces/IPostStatus';
import '../../stylesheets/components/Post.scss';
const PostRoot = ({ postId, postStatuses, isLoggedIn, isPowerUser, authenticityToken }) => (
<Provider store={store}>
<Post
postId={postId}
postStatuses={postStatuses}
interface Props {
postId: number;
postStatuses: Array<IPostStatus>;
isLoggedIn: boolean;
isPowerUser: boolean;
authenticityToken: string;
}
isLoggedIn={isLoggedIn}
isPowerUser={isPowerUser}
authenticityToken={authenticityToken}
/>
</Provider>
);
class PostRoot extends React.Component<Props> {
store: any;
constructor(props) {
super(props);
this.store = createStoreHelper();
}
render() {
const {
postId,
postStatuses,
isLoggedIn,
isPowerUser,
authenticityToken
} = this.props;
return (
<Provider store={this.store}>
<Post
postId={postId}
postStatuses={postStatuses}
isLoggedIn={isLoggedIn}
isPowerUser={isPowerUser}
authenticityToken={authenticityToken}
/>
</Provider>
);
}
}
export default PostRoot;