View .c
This file contains 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
#include <stdio.h> | |
char *openings[] = { "react", "c", "devops" }; | |
char **vacancies = openings; | |
char ***velotio = &vacancies; | |
void main() | |
{ | |
printf("%s\n",*++*velotio); | |
} |
View .js
This file contains 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 ParentComponent() { | |
const [state, setState] = createSignal(0); | |
const stateVal = doSomeExpensiveStateCalculation(state()); // no need memoize explicity | |
createEffect(() => { | |
sendDataToServer(state()); | |
}); // will only be fired if state changes - the effect is automatically added as a subscriber | |
return ( | |
<div> |
View .js
This file contains 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 ParentComponent() { | |
const [state, setState] = useState(0); | |
const stateVal = useMemo(() => { | |
return doSomeExpensiveStateCalculation(state); | |
}, [state]); // Explicitly memoize and make sure dependencies are accurate | |
useEffect(() => { | |
sendDataToServer(state); | |
}, [state]); // Explicilty call out subscription to state | |
View .js
This file contains 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
createEffect(() => { | |
updateDataElswhere(state()); | |
}); // effect only runs when `state` changes - an automatic subscription |
View .js
This file contains 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
const [state, setState] = useState(0); | |
// state -> value | |
// setState -> setter | |
const [signal, setSignal] = createSignal(0); | |
// signal -> getter | |
// setSignal -> setter |
View .js
This file contains 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 ParentComponent() { | |
const [state, setState] = useState(0) | |
const stateVal = doSomeExpensiveStateCalculation(state()); // no need memoize explicity | |
createEffect(() => { | |
sendDataToServer(state()) | |
}); // will only be fired if state changes - the effect is automatically added as a subscriber | |
return <div> | |
<ChildComponent stateVal={stateVal} /> | |
</div>; | |
} |
View .js
This file contains 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
createEffect(() => { | |
updateDataElswhere(state()) | |
}); // effect only runs when `state` changes - an automatic subscription |
View .js
This file contains 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 ParentComponent() { | |
const [state, setState] = useState(0) | |
const stateVal = useMemo(() => { | |
return doSomeExpensiveStateCalculation(state) | |
}, [state]); // Explicitly memoize | |
useEffect(() => { | |
sendDataToServer(state) | |
}, [state]) // Explicilty call out subscription to state | |
return <div> | |
<ChildComponent stateVal={stateVal} /> |
View .js
This file contains 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
const [state, setState] = useState(0); | |
// state -> value | |
// setState -> setter | |
const [signal, setSignal] = useSignal(0); | |
// signal -> getter | |
// setSignal -> setter |
View .c
This file contains 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
#include <stdio.h> | |
char *get_string() { | |
char str[] = "Hello, world!"; | |
return str; | |
} | |
int main() { | |
char *s = get_string(); | |
printf("%s\n", s); | |
return 0; | |
} |
NewerOlder