Closed
Description
Good day sir !
I'm using this library and so far this is the most simple, and nice resizer for my project !
but I'm trying to programatically resize the section from other component, but nothing happen..
I'm using Resizer.resizeSection as documented, but I got no luck..
first I pass the Resizer instance as state, so I could pass it to other component.
/App/Container
<Container
beforeApplyResizer={resizer => {
this.setState({ resizer }) // set resizer
}}>
{
section.grids.map((grid, i) => {
let comp = [
<GridLayout
key={i}
gridIndex={i}
grid={grid}
resizer={this.state.resizer || null} // then pass it to this component
/>
]
if (section.grids[i + 1]) {
comp.push(<Bar key={'bar_' + i} size={5} style={{ background: '#888888', cursor: 'col-resize' }} />)
}
return comp
})
}
</Container>
within the GridLayout component, then I use the resizer inside my custom handler:
/App/GridLayout
class GridLayout extends Component {
// this is the handler for programatically resize this component
handleResize = (newSize) => {
const { gridIndex, resizer } = this.props
if (resizer) {
resizer.resizeSection(gridIndex, { toSize: newSize }) // nothing happen ...
}
}
render () {
const { grid } = this.props
return (
<Section
defaultSize={grid.width || null}
className={classes.layout}>
<IconButton onClick={this.handleDelete}>
<Delete />
</IconButton>
<IconButton onClick={this.handleDuplicate}>
<ViewAgenda />
</IconButton>
<IconButton onClick={() => this.handleResize(grid.width += 15)}> // triggered in here but nothing happen
<Add />
</IconButton>
<IconButton onClick={() => this.handleResize(grid.width -= 15)}> // triggered in here but nothing happen
<Remove />
</IconButton>
</Section>
)
}
}
Please do explain to me if I get it wrong or there are other approaches..
nice library by the way, really helpful, keep the good work !