Instead of this
When working with React, there were cases where I had to pass props to a child component just to provide it as an argument to a function that was passed down to the same child component. Let’s look at this example.
Above example demonstrates a simple todo list that has only remove functionality ( because who needs new tasks anyway? ). If you look at line 23, you can see that we are passing the function
index to each
Todo component. …
Let’s say you created a login form using react-hook-form.
It will look something like this.
I extracted validation logic into a different file for ease of use.
But now you need to implement another login component in some other part of the website. How do you go about this?
The first way that comes to mind is using the same component and maybe passing in some
props and using
css to customize the different components as needed. This might work if the second login component is the same or slightly different from the first one, but if you…
It can be tricky to debug a NodeJS application if you haven’t worked with docker for long. Let me save you some time!
The dockerfile I am using:
docker-compose.yamlfor main configuration:
2. Create a
debug-compose.yaml for debug configuration:
3. Add this configuration to your vscode
docker-compose -f docker-compose.yaml -f debug-compose.yaml
Docker will combine
debug-compose Overriding the first files configuration with the second. Check docker documentation for details.
5. Go to your vscode debug panel (CTRL + SHIFT + D) select
Docker: Attach to Node from the menu…
I recently had to write tests for a React app that used Redux, React Router and Apollo Graphql. I first tried using enzyme to render the components, but couldn’t get it
to work as intended, so I opted for the react-testing-library.
I took the example from https://testing-library.com/docs/react-testing-library/setup and modified it to use apollo graphql test provider only if the `mocks` option is provided.
And for testing the component: