-
-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doesn't play nice with redux-form #120
Comments
@venil7 have you been able to integrate an ACE editor in a redux-form? |
import React from 'react'
import AceEditor from 'react-ace'
export default function ReduxAce (props) {
const {
input,
theme = 'github',
mode = 'html',
fontSize = 14,
tabSize = 2,
width = '1000px',
height = '500px',
...custom
} = props
return (
<AceEditor
theme={theme}
mode={mode}
fontSize={fontSize}
tabSize={tabSize}
width={width}
height={height}
editorProps={{$blockScrolling: true}}
{...input}
{...custom}
/>
)
} and then use it: import React from 'react'
import { reduxForm } from 'redux-form'
import ReduxAce from './path/to/ReduxAce'
function MyForm (props) {
const { handleSubmit } = props
return (
<form onSubmit={handleSubmit}>
<Field
name='staticHtml'
component={ReduxAce}
/>
</form>
)
}
export default reduxForm({
form: 'edit-static-html',
onSubmit (values, dispatch, props) {
console.log('submit...')
}
})(MyForm) It's as simple as that and it works great! |
I have a similar issue right now. I am using react-ace inside redux-form, as a component passed to Field - just like above. My code is just like jschlieber proposed, take a look: `import React from 'react' import 'brace/mode/javascript'; export default function ReduxAce (props) {
}` and `import React, { Component } from 'react'; const ID = 'id123', NAME = 'name123', SOME_CODE = 'code123'; function mapStateToProps({draft}) { function mapDispatchToProps(dispatch) { class Draft extends Component {
} export default reduxForm({ just before the button I put a comment just now, " // if I put it here, then it suddenly works fine " - so yes, if I put the Ace Editor as is not as a Field component, then its value is not deleted. How you can see, I tried to use the onBlur handler and preserve the value, but I couldn't. Thanks for any hints! |
When used with
redux-form
, andonChange
dispatches a "change" action, this causes AceEditor to re-render and places cursor at the end of editor.. preventing from making any changesThe text was updated successfully, but these errors were encountered: