10 examples of 'textarea in react native' in JavaScript

Every line of 'textarea in react native' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
5function PureTextarea(props) {
6 const id = props.id || props.field.join('.');
7 const {containerClassName,
8 textareaClassName,
9 label,
10 errorMessage,
11 options,
12 isRequired,
13 isTouched,
14 isValid,
15 ...otherProps} = props;
16
17 const containerClasses = {
18 required: isRequired,
19 error: isTouched && !isValid
20 };
21
22 otherProps.defaultValue = undefined;
23 return (
24 <div className={cx(containerClassName, containerClasses)}>
25 <label htmlFor={id}>{label}</label>
26 <textarea {...otherProps} id={id} className={textareaClassName} />
27 <aside className='pure-form-message'>
28 {isTouched ? errorMessage : null}
29 </aside>
30 </div>
31 );
32}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

10function shallowTextArea(props = {}) {
11 const textAreaProps = {
12 ...props
13 };
14 return shallow(<TextArea {...textAreaProps} />);
15}
699function CustomTextarea(props, context) {
700 _classCallCheck(this, CustomTextarea);
701
702 var _this = _possibleConstructorReturn(this, (CustomTextarea.__proto__ || Object.getPrototypeOf(CustomTextarea)).call(this, props, context));
703
704 _this.state = {
705 value: props.value,
706 isChanged: !!props.value,
707 isUsed: false,
708 isChecked: true
709 };
710
711 context.register(_this);
712 return _this;
713 }
705renderTextArea() {
706 this.isEditing = true;
707 const { top, left } = this._comment.getBoundingClientRect();
708 const scrollTop = document.documentElement.scrollTop;
709 this.event = Entry.disposeEvent.attach(this, () => {
710 this._textPath.textContent = this.value;
711 this.destroyTextArea();
712 });
713 this.textArea = Entry.Dom('textarea', {
714 class: 'entry-widget-textarea',
715 parent: $('body'),
716 });
717 this.bindDomEventTextArea();
718 this.textArea.val(this.value);
719 this.textArea.css({
720 left: left - (1 - this.scale) * 0.2 + 2,
721 top: this.titleHeight * this.scale + top + 1 + scrollTop,
722 'font-size': `${this.fontSize}px`,
723 width: (this.width - 16) * this.scale,
724 height: (this.height - this.titleHeight - 10) * this.scale,
725 border: `${this.scale}px solid transparent`,
726 'border-radius': `0 0 ${4 * this.scale}px ${4 * this.scale}px`,
727 padding: `${2 * this.scale}px ${4 * this.scale}px`,
728 });
729 const length = this.value.length;
730 this.textArea.focus &&
731 this.textArea.focus() &&
732 this.textArea[0].setSelectionRange(length, length);
733}
1726function Textarea(props) {
1727 var _this;
1728
1729 _classCallCheck(this, Textarea);
1730
1731 _this = _possibleConstructorReturn(this, _getPrototypeOf(Textarea).call(this, props));
1732 _this.focus = _this.focus.bind(_assertThisInitialized(_this));
1733 return _this;
1734}
6render() {
7 const {
8 inputClass, sizeClass, readOnly, name, value, onChange, id
9 } = this.props;
10 if (readOnly) {
11 return super.render(<div className={sizeClass}>
12 <textarea id={id} rows="8" cols="60" readOnly className={inputClass} name={name} value={value} />
13 </div>);
14 }
15 return super.render(<div className={sizeClass}>
16 <textarea id={id} rows="8" cols="60" className={inputClass} name={name} value={value} onChange={onChange} />
17 </div>);
18}
574function insertText(textarea, _ref) {
575 var text = _ref.text,
576 selectionStart = _ref.selectionStart,
577 selectionEnd = _ref.selectionEnd;
578
579 var originalSelectionStart = textarea.selectionStart;
580 var before = textarea.value.slice(0, originalSelectionStart);
581 var after = textarea.value.slice(textarea.selectionEnd);
582
583 if (canInsertText === null || canInsertText === true) {
584 try {
585 canInsertText = document.execCommand('insertText', false, text);
586 } catch (error) {
587 canInsertText = false;
588 }
589 }
590
591 if (canInsertText && !textarea.value.slice(0, textarea.selectionStart).endsWith(text)) {
592 canInsertText = false;
593 }
594
595 if (!canInsertText) {
596 try {
597 document.execCommand('ms-beginUndoUnit');
598 } catch (e) {
599 // Do nothing.
600 }
601 textarea.value = before + text + after;
602 try {
603 document.execCommand('ms-endUndoUnit');
604 } catch (e) {
605 // Do nothing.
606 }
607 textarea.dispatchEvent(new CustomEvent('input', { bubbles: true, cancelable: true }));
608 }
609
610 if (selectionStart != null && selectionEnd != null) {
611 textarea.setSelectionRange(selectionStart, selectionEnd);
612 } else {
613 textarea.setSelectionRange(originalSelectionStart, textarea.selectionEnd);
614 }
615}
132function TextareaEditor(props) {
133 _classCallCheck(this, TextareaEditor);
134
135 var _this = _possibleConstructorReturn(this, (TextareaEditor.__proto__ || Object.getPrototypeOf(TextareaEditor)).call(this, props));
136
137 _this.config = props.config;
138 _this.config.editor = _this;
139
140 _this.editorRef = _react2.default.createRef();
141 _this.handleInput = _this.handleInput.bind(_this);
142 return _this;
143}
22componentWillReceiveProps(nextProps: TextareaProps) {
23 if ('value' in nextProps && this.props.value !== nextProps.value) {
24 this.setState({
25 value: nextProps.value!,
26 });
27 }
28}
56render() {
57
58 return (
59 <View style={{ flex: 1 }}>
60 <TextInput ref={c => this._root = c} {...this.prepareRootProps()} multiline={true} placeholderTextColor={ this.getTheme().inputColorPlaceholder} underlineColorAndroid='rgba(0,0,0,0)' />
61 </View>
62 );
63}

Related snippets