- React import removed from
rfe
for typescriptreact, andrfie
added to support previous behavior. This is due to all the .tsx snippets not importing React by default because best practice is to use the newerjsx
transpiler that is separate from React, thus no import is needed to render JSX on it's own.
- Typescript support for
.ts
and.tsx
files! - Readme update to highlight the keys in each shortcut
- React hook snippets for
useState
,useEffect
imports and statements, and a bootstrap withuseState
. It took me a while to figure out theuseState
statement, because I really wanted the[state, useState]
destructed variables to use one placeholder and capitalize the first character afteruse
. Turns out you can do this with a regexp capture but with the Vim vscode extension it does not play nicely. So it works without Vim, but I haven't figured it out for Vim yet. - Added a PropTypes (
pt
) snippet for setting up theMyComponent.propTypes
object in case you decided to add it after creating a component. It uses the filename as the default. - Here are the new snippet commands (you can see the whole list in the README)
- Some snippets, such as
rfpe
(create React component with PropTypes object) would not autocomplete snippets until the entire snippet was exited. This is how VSCode snippets work, however, I have learned that you can set the ending point of a snippet ($0
for the curious) where you like, rather than the end of the code that was added. This allows thepropTypes
object snippet to behave as intended, without having to hit Escape or Ctrl+Space to type further snippets inside the object.
- Testing: expect.toBe(), expect.toBeNull()
- PropTypes.shape({}) snippets
- react-testing-library has updated to @testing-library/react since this project started, and there have been a few changes to best practices and syntax.
One of those changes is that
.firstChild
is not required when using container to snapshot or query against.container.firstChild
snippets have switched to simplycontainer
. - The
rtlbs
snippet (React Testing Library Bootstrap) has had some updates after watching Kent Dodds updated testing course.render
is a named export, rather than the default, and I've swapped thesetup-tests
file import with the actual package. This is an extra step for me to type, but it's more universally useful. At least that's the hope.
- React Testing Library bootstrap for setting up basic component test with the root name of the file (no file extensions)
- React Testing Library snapshot snippet
- Jest
test
block snippet
- Add Storybook snippet for setting up a basic component story based on the root name of the file (no file extensions)
- Add react component with proptypes and default export snippet
- Add react component snippet without any imports or exports for multi-component files
- Add alternative snippet shortcut
rfe
(react functional export) forrse
(react stateless functional export) due to hooks allowing state in functional components now
- Update styled component callback snippets to have a semicolon at the end (required to compile).
- Add reference in readme
styled-components-snippets.json
so that styled component css is not flooded with our JS snippets
- Moved styled components snippets from
snippets.json
to the new snippet file for styled components - Changed styled component functions to include their parameter in the default typing area
- Styled Component imports for
styled-components
and@emotion/styled
- Styled Component creation snippet
- Styled Component function interpolations
- Changed enzyme shortcut from
ime
toimez
because I use it less and wantedimes
for@emotion/styled
- Testing blocks (e.g. describe, it)
- expect to match snapshot, and expect to equal
- Enzyme shallow and mount imports
- Import React, React with Component, and PropTypes
- Console log group snippets
- React lifecycle method snippets
- PropType snippets
- Swapped hard spaces for tab character in multiline snippets with indentation. The
\t
should be more friendly for users with 2 or 4 space tabs (or even 3, if you are Satan incarnate).
- Console log snippets (default and with a color)