Skip to content

Conversation

@JodusNodus
Copy link
Contributor

  • Allow parent component to interact with code mirror instance created in the child.
  • Updated build

I needed this for my project and i thought others might need it too.

Cheers, 🎄

@JedWatson
Copy link
Owner

Thanks @JodusNodus, I'll add a check to make sure interact is defined, but otherwise looks good 😃

JedWatson added a commit that referenced this pull request Dec 29, 2015
Allow interaction with codemirror object from parent.
@JedWatsonJedWatson merged commit 0dbfb61 into JedWatson:masterDec 29, 2015
@JedWatson
Copy link
Owner

Actually... edit

Wouldn't it be cleaner (and more React-y) to just use a ref for the react-codemirror component, and use its getCodeMirror method on the parent component's componentDidMount to interact with the CodeMirror instance?

This basically provides the same effect without the need for an interact prop:

// ... componentDidMount (){this.refs.cm.getCodeMirror().doSomething()}, render (){return <CodeMirror ref="cm" />} // ... 

@JodusNodus
Copy link
ContributorAuthor

Indeed that looks better. Just tested that and that seems to work great. Thanks, didn't know you could acces the component methods using the reference. 👍

JedWatson added a commit that referenced this pull request Dec 29, 2015
JedWatson added a commit that referenced this pull request Dec 29, 2015
Including clarification of how to access the CodeMirror instance after `componentDidMount` has fired, ref #27
@JedWatson
Copy link
Owner

Glad that resolves it - I've rolled the change back and updated the docs to make it clearer.

@guidobouman
Copy link

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@JodusNodus@JedWatson@guidobouman