2

I wrote a simple Atom.io snippet for ReactJS:

'.text.js':
'React Component':
'prefix': 'rrc'
'body': 'var Component = React.createClass({ 
                render: function(){
                    return { 
                        ; 
                    }  
                } 
            })'

I saved this to

atom/resources/app/dot-atom/snippets.cson

file where snippets live, and after trying it by typing 'rrc' and hitting tab key, I got only a blank space.

I googled around and other people were having similar problem, but I found no solution that worked for me.

2 Answers 2

2

According to Atom's snippet documentation it appears that the source selector should be '.source.js' rather than '.text.js'

Also, you'll need to make it a multiline snippet as well:

'.source.js':
  'React Component':
  'prefix': 'rrc'
  'body': """
     var Component = React.createClass({ 
        render: function(){
          return { 
              ; 
          }  
        } 
      })
   """
Sign up to request clarification or add additional context in comments.

2 Comments

You are right, but still no luck - when I type rrc and hit tab nothing happens. :(
I was able to get this to work by retyping it into my snippets.cson. Unfortunately, there seems to be an issue with snippets not triggering properly because I have new snippets in my file that do not trigger when multiple source classes are used in the snippets file. Here's the bug: link
0

Try this, content is exactly as provided by josh, but try to keep the exact spacing. I just tried it on 1.12.3 and no issues.

'.source.js':
  'React Component':
    'prefix': 'rrc'
    'body': """
    var Component = React.createClass({ 
        render: function(){
            return {
                ;
            }
        }
    })"""

snippet

Open new tab, give the proper syntax.

set proper syntax

Type rrc then tab, or enter if you select from the autocomplete.

autocomplete should suggest snippet

snippet is expanded

1 Comment

Please put the code directly into the post and not in an image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.