start playing with react router
This commit is contained in:
parent
bee6fd695a
commit
4d05a6a099
@ -5,10 +5,11 @@
|
|||||||
"lint": "tslint --project tslint.json",
|
"lint": "tslint --project tslint.json",
|
||||||
"package": "yarn build -- --config webpack.config.prod.js --bail --display-used-exports -p",
|
"package": "yarn build -- --config webpack.config.prod.js --bail --display-used-exports -p",
|
||||||
"package-for-test": "yarn build -- --config webpack.config.test.js --bail --display-used-exports",
|
"package-for-test": "yarn build -- --config webpack.config.test.js --bail --display-used-exports",
|
||||||
"watch": "yarn build -- --config webpack.config.js --colors --debug --output-pathinfo --progress --watch",
|
"watch": "yarn build -- --config webpack.config.js --colors --debug --output-pathinfo --progress --watch --env.WARN_ON_LINT",
|
||||||
"build": "node ./node_modules/webpack/bin/webpack.js --cache=true --display-error-details --profile",
|
"build": "node ./node_modules/webpack/bin/webpack.js --cache=true --display-error-details --profile",
|
||||||
"clean": "rm -rf ./dist/*",
|
"clean": "rm -rf ./dist/*",
|
||||||
"tsnode": "node -r ts-node/register -r tsconfig-paths/register"
|
"tsnode": "node -r ts-node/register -r tsconfig-paths/register",
|
||||||
|
"start:dev": "webpack-dev-server"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.2.2",
|
"@babel/core": "^7.2.2",
|
||||||
@ -25,6 +26,7 @@
|
|||||||
"@types/react-dom": "^16.0.11",
|
"@types/react-dom": "^16.0.11",
|
||||||
"@types/react-measure": "^2.0.4",
|
"@types/react-measure": "^2.0.4",
|
||||||
"@types/react-redux": "^6.0.12",
|
"@types/react-redux": "^6.0.12",
|
||||||
|
"@types/react-router-dom": "^4.3.1",
|
||||||
"@types/react-window": "^1.1.0",
|
"@types/react-window": "^1.1.0",
|
||||||
"babel-loader": "^8.0.4",
|
"babel-loader": "^8.0.4",
|
||||||
"babel-plugin-transform-builtin-extend": "^1.1.2",
|
"babel-plugin-transform-builtin-extend": "^1.1.2",
|
||||||
@ -61,6 +63,7 @@
|
|||||||
"typescript": "^3.2.2",
|
"typescript": "^3.2.2",
|
||||||
"webpack": "^4.28.3",
|
"webpack": "^4.28.3",
|
||||||
"webpack-cli": "^3.1.2",
|
"webpack-cli": "^3.1.2",
|
||||||
|
"webpack-dev-server": "^3.1.14",
|
||||||
"webpack-shell-plugin": "^0.5.0"
|
"webpack-shell-plugin": "^0.5.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -72,6 +75,7 @@
|
|||||||
"react-dom": "^16.7.0",
|
"react-dom": "^16.7.0",
|
||||||
"react-measure": "^2.2.2",
|
"react-measure": "^2.2.2",
|
||||||
"react-redux": "^6.0.0",
|
"react-redux": "^6.0.0",
|
||||||
|
"react-router-dom": "^4.3.1",
|
||||||
"react-window": "^1.5.0",
|
"react-window": "^1.5.0",
|
||||||
"redux": "^4.0.1",
|
"redux": "^4.0.1",
|
||||||
"redux-thunk": "^2.3.0",
|
"redux-thunk": "^2.3.0",
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import POGOProtos from 'pogo-protos';
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ContentRect, default as Measure } from 'react-measure';
|
import { ContentRect, default as Measure } from 'react-measure';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import { VariableSizeList } from 'react-window';
|
import { VariableSizeList } from 'react-window';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@ -165,8 +166,15 @@ export class PokemonSelectList extends React.Component<IPokemonSelectListProps,
|
|||||||
styles.form
|
styles.form
|
||||||
);
|
);
|
||||||
const onClick = () => this.props.handleActivatePokemon(pokemon.id, pokemon.form);
|
const onClick = () => this.props.handleActivatePokemon(pokemon.id, pokemon.form);
|
||||||
|
const linkTo = {
|
||||||
|
// pathname: '/courses',
|
||||||
|
search: `?id=${pokemon.id}`,
|
||||||
|
// hash: '#the-hash',
|
||||||
|
// state: { fromDashboard: true }
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<a
|
<Link
|
||||||
|
to={ linkTo }
|
||||||
key={ this.getListItemKey(index) }
|
key={ this.getListItemKey(index) }
|
||||||
style={ style }
|
style={ style }
|
||||||
className={ anchorCss }
|
className={ anchorCss }
|
||||||
@ -178,7 +186,7 @@ export class PokemonSelectList extends React.Component<IPokemonSelectListProps,
|
|||||||
{ pokemon.form !== POGOProtos.Enums.Form.FORM_UNSET &&
|
{ pokemon.form !== POGOProtos.Enums.Form.FORM_UNSET &&
|
||||||
<span className={ formCss }>{ formatForm(pokemon.form) } Form</span>
|
<span className={ formCss }>{ formatForm(pokemon.form) } Form</span>
|
||||||
}
|
}
|
||||||
</a>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
padding: 5px 1em 5px 2.25em;
|
padding: 5px 1em 5px 2.25em;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
align-content: space-around;
|
align-content: space-around;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDOM from 'react-dom';
|
import * as ReactDOM from 'react-dom';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
|
import { BrowserRouter as Router, Route } from 'react-router-dom';
|
||||||
import * as Redux from 'redux';
|
import * as Redux from 'redux';
|
||||||
import thunk from 'redux-thunk';
|
import thunk from 'redux-thunk';
|
||||||
|
|
||||||
@ -34,7 +35,12 @@ const store = Redux.createStore(
|
|||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Provider store={ store }>
|
<Provider store={ store }>
|
||||||
<ConnectedPokemonApp />
|
<Router>
|
||||||
|
<div>
|
||||||
|
<Route exact={ true } path="/" component={ ConnectedPokemonApp } />
|
||||||
|
<Route path="/test" render={ () => <h1>hello</h1> } />
|
||||||
|
</div>
|
||||||
|
</Router>
|
||||||
</Provider>,
|
</Provider>,
|
||||||
document.getElementById('pokemon-mount')
|
document.getElementById('pokemon-mount')
|
||||||
);
|
);
|
||||||
|
|||||||
@ -32,6 +32,9 @@ module.exports = function (env) {
|
|||||||
].concat(options.getPlugins(env));
|
].concat(options.getPlugins(env));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
devServer: {
|
||||||
|
historyApiFallback: true,
|
||||||
|
},
|
||||||
entry: {
|
entry: {
|
||||||
'global': [
|
'global': [
|
||||||
'@babel/polyfill', // this is intended to be on every single page, legacy or new!
|
'@babel/polyfill', // this is intended to be on every single page, legacy or new!
|
||||||
|
|||||||
@ -7,6 +7,7 @@ const StyleLintPlugin = require('stylelint-webpack-plugin');
|
|||||||
module.exports = function(env) {
|
module.exports = function(env) {
|
||||||
var generatedConfig = config(env, false);
|
var generatedConfig = config(env, false);
|
||||||
|
|
||||||
|
delete generatedConfig.devServer;
|
||||||
generatedConfig.mode = 'production';
|
generatedConfig.mode = 'production';
|
||||||
generatedConfig.plugins = [
|
generatedConfig.plugins = [
|
||||||
new webpack.LoaderOptionsPlugin({
|
new webpack.LoaderOptionsPlugin({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user