4 ms·
I'm not sure I follow your question. It's Javascript. Code goes from top to bottom. You can't write: function doThing(target) { console.log(myVar);
by ArchReaper 7y ago
I'm not sure I follow your question. It's Javascript. Code goes from top to bottom. You can't write:
function doThing(target) {
console.log(myVar);
const myVar = target.prop;
}
Because that's invalid Javascript. React Hooks are just functions that return markup.
If your goal is simply to see what it renders first, that's fine, you simply need to look at what the function returns.
I disagree with your assertion that LSFF is 'backwards' - it is simply not what you are used to.
MSFF could definitely be argued for class-based components, but it's simply not an option for hook-based components.
- Izkata 7y agoThey didn't write that, they wrote this: function doThing(target) { function run() { console.log(myVar); } const myVar = target.prop; run(); } The console.log's evaluation is delayed, so it's totally valid.