I am trying to make a component with a dynamic size based on its props. Currently, I am testing it with the following setup, however when I adjust the slider, the component doesn't change size
// View.js
import React, { Component } from 'react';
import Cell from './Cell'
export default class View extends Component {
constructor(props) {
super(props);
this.handleSlide = this.handleSlide.bind(this);
this.state = {
cellSize: 50
};
}
handleSlide(event) {
this.setState({
cellSize: event.target.value
});
}
render() {
return (
<div>
<input type="range" min="1" max="100" value={this.state.cellSize} onChange={this.handleSlide} />
<Cell size={this.state.cellSize}/>
</div>
);
}
}
// Cell.js
import React, { Component } from 'react';
export default class Cell extends Component {
render() {
const cellSize = {
width: this.props.size,
height: this.props.size
}
return (
<div style={cellSize}>
</div>
);
}
}
What am I doing wrong