The standard way to use a React useState Hook is the following:
const [count, setCount] = useState(0);
Run Code Online (Sandbox Code Playgroud)
However this const count
variable is clearly going to be reassigned to a different primitive value.
Why then is the variable not defined as let count
?
鉴于:
class Account < ApplicationRecord
belongs_to :super_account, class_name: 'Account', optional: true, foreign_key: 'account_id'
has_many :sub_accounts, class_name: 'Account'
end
Run Code Online (Sandbox Code Playgroud)
查找没有 sub_accounts 的所有帐户的 rails 方法是什么?