handleSubmit(e) { e.preventDefault() const node = this.refs.input const text = node.value.trim() if (text) { this.props.onAddSubmit(text) node.value = '' } }
render() { return ( <ApolloProvider client={this.apolloClient}> <ReduxProvider store={this.reduxStore}> <Component {...this.props} /> </ReduxProvider> </ApolloProvider> ); }
<ApolloProvider client={client}> <ReduxProvider store={store}> <Component {...props} /> </ReduxProvider> </ApolloProvider>
setTime(e,flag){ let audio = this.refs.audio; let targetPoint = e.touches[0].pageX-this.state.playedLeft if(flag){ targetPoint = e.touches[0].pageX- this.state.detailPlayedLeft var newWidth = targetPoint/this.refs.detailProgress.offsetWidth; }else{ var newWidth = targetPoint/this.refs.progress.offsetWidth; } this.refs.played.style.width = newWidth*100 + "%"; audio.currentTime = newWidth*audio.duration }
refs .map(r => this.refs[r]) .filter(r => r) .map(r => r.fadeOutRight(400)) .concat([backButton.fadeOutLeft(400)])
it('type', () => { const wrapper = mount( <Field defaultValue="notanemail" id="email" name="email" type="email" />, ); wrapper .find('input') .instance() .dispatchEvent(new window.Event('invalid', { bubbles: true })); expect(wrapper).toHaveState('invalid', true); expect(wrapper).toHaveState('errorMessage', 'This value is not an email.'); });
setViewState(state, cb) { const el = this.getWrappedInstance(); if (el) { el.setState(state, cb); } }
//SD:Event handlers navigation menu items handleShowDisplayRecords() { let overlay = this.refs.overlay; overlay.show(); let data = this.model.displayAllRecords(); overlay.displayRecords(data); }
it('selected value through select element', () => { const wrapper = mount(<Select options={options} placeholder="Pick a color" />); const $select = wrapper.find('select'); const $fakeSelectOption = wrapper.find('.selected-option'); expect($select.instance().value).toStrictEqual(''); expect($fakeSelectOption).toHaveText('Pick a color'); $select.instance().value = 'blue'; $select.first().simulate('change', { target: { value: 'blue' } }); expect(wrapper).toHaveState('value', 'blue'); expect($fakeSelectOption).toHaveText('blue'); expect($select.instance().value).toStrictEqual('blue'); });
moveProgress(e,flag){ let audio = this.refs.audio; if(audio.currentTime !== 0){ this.setTime(e,flag) } }
handleClick(e) { const node = this.refs.input const text = node.value.trim() this.props.onAddClick(text) node.value = '' }