Skip to content

Instantly share code, notes, and snippets.

View madan712's full-sized avatar

Madan Chaudhary madan712

View GitHub Profile
@madan712
madan712 / App.js
Created June 1, 2019 10:32
App.js - Example with React, Redux and Axios API
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as appAction from './AppAction';
class App extends Component {
constructor(props, context) {
super(props, context);
this.submit = this.submit.bind(this);
this.updateName = this.updateName.bind(this);
@madan712
madan712 / Index.js
Created March 31, 2019 12:15
Index.js - Simple React + Redux example
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import {Provider} from 'react-redux';
import AppStore from "./AppStore";
ReactDOM.render(<Provider store={AppStore}><App/></Provider>, document.getElementById('root'));
@madan712
madan712 / AppStore.js
Created March 31, 2019 12:14
AppStore.js - Simple React + Redux example
import {createStore} from 'redux';
import AppReducer from "./AppReducer";
const AppStore = createStore(AppReducer);
export default AppStore;
@madan712
madan712 / AppReducer.js
Created March 31, 2019 12:14
AppReducer.js - Simple React + Redux example
const initialState = {
count: 0
};
export default function AppReducer(state = initialState, action) {
const newState = Object.assign({}, state);
switch (action.type) {
case 'INCREMENT':
newState.count = newState.count + 1;
return newState;
@madan712
madan712 / AppAction.js
Created March 31, 2019 12:13
AppAction.js - Simple React + Redux example
export function increment() {
return {type: 'INCREMENT'};
}
export function decrement() {
return {type: 'DECREMENT'};
}
@madan712
madan712 / App.js
Last active March 31, 2019 12:16
App.js - Simple React + Redux example
import React, {Component} from 'react';
import './App.css';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import * as appAction from './AppAction';
class App extends Component {
render() {
return (
<div className="App">
@madan712
madan712 / App.js
Created March 23, 2019 11:29
App.js - Spring Boot + ReactJS hello world example
import React, {Component} from 'react';
import './App.css';
import axios from 'axios';
class App extends Component {
constructor(props) {
super(props);
this.state = {message: ''};
}
@madan712
madan712 / ApplicationController.java
Created March 23, 2019 11:21
ApplicationController.java - Spring Boot + ReactJS hello world example
package com.javaxp;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ApplicationController {
@madan712
madan712 / Application.java
Last active March 23, 2019 11:19
Application.java - Spring Boot + ReactJS hello world example
package com.javaxp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application
{
public static void main( String[] args )
{
@madan712
madan712 / pom.xml
Last active March 23, 2020 18:16
pom.xml - Spring Boot + ReactJS hello world example
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javaxp</groupId>
<artifactId>java-app</artifactId>
<version>1.0-SNAPSHOT</version>