There are some interesting quick to learn debugging process in react that will increase your efficiency a lot. I will skip the console.log just to save time.
Just put this code in your react application
React has a cool chrome/firefox extension that is very good for debugging react components states and props.
// Header.tsx
const Header = () => {
debugger;
return (
<ThemeContext.Consumer>
{({ theme, setTheme }) => (
<NavBar>
<NavSwitch
theme={theme}
onClick={() => {
setTheme(revertThemes[theme.themeName]);
}}
></NavSwitch>
</NavBar>
)}
</ThemeContext.Consumer>
);
};
export default Header;
Run the dev server. Once your code reaches that place your browser will stop there and look like this
You can simply move your cursor on top of those variables and you will be able to see the values of the variables. You can also set your breakpoints at this moment.
You can start your react server and check the states and Props using this tool for each react component.
Using this tool will show you the options components and Profiler.
