diff --git a/snippets/LimitedTextarea b/snippets/LimitedTextarea new file mode 100644 index 000000000..74859fa66 --- /dev/null +++ b/snippets/LimitedTextarea @@ -0,0 +1,48 @@ +### LimitedTextarea + +Renders a textarea component with a character limit. + +Use the value of the `value` prop to determine the initial `state.content` and `state.characterCount` and the value of the `limit` props to determine the value of `state.limit`. +Create a method, `handleChange`, which trims the `event.target.value` data if necessary and uses `Component.prototype.setState` to update `state.content` and `state.characterCount`, and bind it to the component's context. +In the`render()` method, use a`
` to wrap both the` +

{this.state.characterCount}/{this.props.limit}

+
+ ); + } +} +``` + +```jsx +ReactDOM.render( + , + document.getElementById('root') +); +``` + +< !--tags: input,state,class -- > + +< !--expertise: 0 -- > +