-
Notifications
You must be signed in to change notification settings - Fork 2
Add react tip button #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
| "description": "", | ||
| "main": "dist/index.js", | ||
| "browser": "dist/index.js", | ||
| "dependencies": {}, | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
|
|
@@ -27,6 +26,10 @@ | |
| "webpack": "^4.44.1", | ||
| "webpack-cli": "^3.3.12" | ||
| }, | ||
| "optionalDependencies": { | ||
| "prop-types": "^15.7.2", | ||
| "react": "^17.0.0" | ||
|
Comment on lines
+30
to
+31
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, these dependencies are inlined into the bundle, let's use externals to keep them extracted.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope that will help with that, I will add it externals: {
'prop-types': 'prop-types',
'react': 'react'
},
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The general idea is not to hope but to test it using a bundle analyzer and trying to use it in different environments
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will check it at Monday's morning |
||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "start": "npm run build && serve", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import createButton from './button'; | ||
|
|
||
| export default class Button extends React.Component { | ||
| constructor(props) { | ||
| super(props); | ||
| this.button = React.createRef(); | ||
| this.componentDidMount = this.componentDidUpdate = () => | ||
| createButton(this.button.current, this.props); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While working on #38 I have found that the replacement of the DOM node breaks subsequent component updates. I have fixed it there by using a different API. |
||
| } | ||
|
|
||
| render() { | ||
| return React.createElement('div', { ref: this.button }); | ||
| } | ||
| }; | ||
|
|
||
| Button.propTypes = { | ||
| size: PropTypes.oneOf(['icon', 'small', 'medium', 'large']), | ||
| url: PropTypes.string, | ||
| account: PropTypes.string, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,19 @@ const path = require('path'); | |
| const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
| const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | ||
|
|
||
| const genConfig = (filename, { inlineCss } = {}) => ({ | ||
| const genConfig = (outputFilename, { inlineCss, inputFilename = 'index.js' } = {}) => ({ | ||
| output: { | ||
| path: path.resolve(__dirname, 'dist'), | ||
| filename, | ||
| filename: outputFilename, | ||
| library: 'superheroUtils', | ||
| libraryTarget: 'umd' | ||
| }, | ||
| entry: `./src/${inputFilename}`, | ||
| target: 'web', | ||
| externals: { | ||
| 'prop-types': 'prop-types', | ||
| 'react': 'react' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this is not working if imported using the |
||
| }, | ||
| module: { | ||
| rules: [ | ||
| { | ||
|
|
@@ -40,4 +45,5 @@ const genConfig = (filename, { inlineCss } = {}) => ({ | |
| module.exports = [ | ||
| genConfig('index-without-styles.js'), | ||
| genConfig('index.js', { inlineCss: true }), | ||
| genConfig('button-react.js', { inputFilename: 'button-react.js'}), | ||
| ]; | ||
Uh oh!
There was an error while loading. Please reload this page.