1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-26 15:04:19 +01:00
ipfs-boards/src/containers/Board.js

44 lines
1010 B
JavaScript
Raw Normal View History

2018-02-04 19:08:21 +01:00
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { push } from 'react-router-redux'
import BoardComponent from '../components/Board'
import { createBoard } from '../actions/board'
class Board extends Component {
componentDidMount() {
const { boards, match } = this.props
if (!boards[match.params.boardId]) {
this.props.openBoard(match.params.boardId)
}
}
render() {
const { boards, match } = this.props
const id = match.params.boardId
const board = boards[id]
if (board) {
return <BoardComponent {...board} />
} else {
return <div>Opening this board...</div>
}
}
}
function mapStateToProps(state){
return {
boards: state.boards.boards
}
}
function mapDispatchToProps(dispatch){
return {
openBoard: id => dispatch(createBoard(id))
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(Board)