All "React" Snippets
perfHasChanged
Generate a console log to detect when a value has changed.
<template name="perfHasChanged" value="useEffect(() => { console.log("[Perf: ⚡️Value changed] $DEPENDENCY_NAME$ has changed in $COMPONENT_NAME$", $DEPENDENCY_VALUE$); }, [$DEPENDENCY$])" toReformat="false" toShortenFQNames="true">
<variable name="DEPENDENCY" expression="completeSmart()" defaultValue="" alwaysStopAt="true" />
<variable name="COMPONENT_NAME" expression="jsMethodName()" defaultValue="" alwaysStopAt="false" />
<variable name="DEPENDENCY_VALUE" expression="DEPENDENCY" defaultValue="" alwaysStopAt="false" />
<variable name="DEPENDENCY_NAME" expression="capitalize(DEPENDENCY)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JS_STATEMENT" value="true" />
<option name="TS_STATEMENT" value="true" />
</context>
</template>
Live template
perfHasChanged
Generate a console log to detect when a value has changed.
<template name="perfMount" value="useEffect(() => { console.log('[Perf: 📦 Mounted] $COMPONENT_NAME$') }, [])$END$" description="Add log to see component mounting" toReformat="false" toShortenFQNames="true">
<variable name="COMPONENT_NAME" expression="jsMethodName()" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JS_STATEMENT" value="true" />
<option name="TS_STATEMENT" value="true" />
</context>
</template>
Live template
Do you speak French and want to stop hating your tests ?
I've created a course to help developers to improve their automated tests.
I share ideas and technics to improve slow, flaky, failing for unexpected reason and hard to understand tests until they become tests we take joy to work with !
But you'll need to understand French...
perfRender
Generate a console log helping to detect React component rendering.
<template name="perfRender" value="console.log('[Perf: 🔄 Render] $COMPONENT_NAME$')$END$" description="Add log to see component re-rendering" toReformat="false" toShortenFQNames="true">
<variable name="COMPONENT_NAME" expression="jsMethodName()" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JS_STATEMENT" value="true" />
<option name="TS_STATEMENT" value="true" />
</context>
</template>
Live template