Method | Side effects1 | State updates2 | Example uses |
---|---|---|---|
Mounting | |||
componentWillMount |
✓ | Constructor equivalent for createClass |
|
render |
Create and return element(s) | ||
componentDidMount |
✓ | ✓ | DOM manipulations, network requests, etc. |
Updating | |||
componentWillReceiveProps |
✓ | Update state based on changed props |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export imports | |
import d, {obj} from '...'; | |
export {obj, d}; | |
export {obj as name1, d as name2}; | |
re-export all named imports | |
export * from '...'; | |
export * as name1 from '...'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function on(node, eventType, selector, fn){ | |
node.addEventListener(eventType, (e)=>{ | |
let el = e.target | |
while (el && !el.matches(selector)) { | |
el = el.parentNode | |
if(node === el){ el = null } | |
} | |
if(el){ fn.call(el, e, el) } | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model: | |
class User < ActiveRecord::Base | |
ROLES = [ | |
[I18n.t('role.admin'), 'admin'], | |
[I18n.t('role.manager'), 'manager'], | |
[I18n.t('role.user'), 'user'] | |
] | |
end | |
locale: | |
en: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<title>这是一个合法的 HTML 5 文档</title> | |
<meta charset="UTF-8"> | |
<p>这是一个合法的 HTML 5 文档 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://askubuntu.com/questions/814/how-to-run-scripts-on-start-up/816#816 | |
One approach is to add an @reboot cron task: | |
Running crontab -e will allow you to edit your cron. | |
Adding a line like this to it: | |
@reboot /path/to/script | |
will execute that script once your computer boots up. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Classes are the only place CoffeeScript generates named functions. | |
# This might seem messy, but the extra wrapping is necessary in order | |
# to have consistent behavior in IE. See the FAQ for more details: | |
# https://github.com/jashkenas/coffee-script/wiki/FAQ | |
class square | |
constructor: (x) -> return x * x # constructors require an explicit return | |
console.log square 5 # 25 | |
console.log square.name # square |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= search_form_for @q, url: production_status_changes_path, class: 'form-inline' do |f| %> | |
<%= f.label 'Create At' %> | |
<%= f.search_field :created_at_beginning_of_day, class: 'form-control input-sm', 'datepicker' => true %> | |
<%= f.search_field :created_at_end_of_day_lt, class: 'form-control input-sm', 'datepicker' => true %> | |
<% end %> |