Enable google analytics with react-router
One way of doing this is to create your own Router class, which extends the one from the framework; and inside this Router class you put in the tracking logic:
One way of doing this is to create your own Router class, which extends the one from the framework; and inside this Router class you put in the tracking logic:
window.history.pushState() won’t be recognised by react-router’s observer. So what will happen is that the url of the browser will be changed, but the corresponding component won’t be loaded. React Router is based on History API, and History.push() will work.
The logic: Show a component only if the user logged in To use it, just
What you need to, Return ResponseEntity<Void> Set the @ResponseStatus for your rest controller’s method If you don’t do that, you will get ResponseEntity as the response class in your swagger json, and you will get both 200 and 204 as your successful response code, which is not correct because your method only returns 204, no …
Problem When you go to a react component, then go to another, and finally come back, the react component is showing blank, or half-blank. Investigation If you inspect the page with the mobile safari inspector , you can see the elements are there, but safari just refuse to show the data on the screen. In …
IOS Safari showing a blank page when coming back to a React Component Read More »
import * as someModule from “../SomeModule”; test(“xxx”, ()=>{ const mockedModule = someModule as jest.Mocked < typeof someModule > ; mockedModule.someFunction = jest.fn(); … //reference the mocked function expect(mockedModule.someFunction.mock.calls.length).toBe(1); });
Jetty is too smart. If there is any JVM option provided, Jetty will spawn a new JVM instance to do the real work, even if you don’t use “–exec” option in start.ini And jetty’s logback module introduces a JVM option. See here You will see: -Dorg.eclipse.jetty.util.log.class?=org.eclipse.jetty.util.log.Slf4jLog So does it matter? It matters a lot because …
Jetty’s start.jar forks a new JVM to run the app if logback module is enabled Read More »
File change monitoring doesn’t work, such as the auto-refresh of create-react-app Use the following before your "npm start" or put it on env file: CHOKIDAR_USEPOLLING=true And if you are using Intellij, you need to explicitly "ctrl + s" to save the changes on your code files Integrate beyond compare with git diff export TMPDIR=’/mnt/c/Users/yourName/AppData/Local/Temp’ alias …
Miscellaneous tips while developing in WSL (Windows Subsystem for Linux) Read More »
Some say you should use the jsx-global-plugin like “@global body{fontFamily:’someFont’}” , but it doesn’t work in my project. The global CSS still has the lower CSS speciality than MUI components’ CSS because this global CSS is using a type selector. You should use a theme instead //create a theme const myTheme = createMuiTheme({ typography: { …
Change the font family globally in Material-UI 3.x Read More »
compile ‘io.springfox:springfox-swagger2:2.9.2’ compile ‘io.springfox:springfox-swagger-ui:2.9.2’ /** See https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api */ @Configuration @EnableSwagger2 public class SwaggerConfig { @Value(“${enable.swagger}”) //You may want to disabled it in PROD boolean enableSwagger; @Bean public Docket api() { Docket api = new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage(“your.package”)) .paths(PathSelectors.any()) .build(); ApiInfo apiInfo = new ApiInfoBuilder() .version(“xxx”) .description(“xxx”) .termsOfServiceUrl(“xxx”) .title(“Xxx Doc”) .build(); api.useDefaultResponseMessages(false).apiInfo(apiInfo); api.enable(enableSwagger); return api; } …