Skip to content

Commit

Permalink
feat: Use React ⚛️ instead of preact
Browse files Browse the repository at this point in the history
  • Loading branch information
Enguerran committed Oct 8, 2018
1 parent a03d9fd commit 84065b1
Show file tree
Hide file tree
Showing 10 changed files with 3,615 additions and 2,537 deletions.
4 changes: 1 addition & 3 deletions docs/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ module.exports = {
},
{
name: 'List',
components: () => [
'../react/ListItemText/index.jsx'
]
components: () => ['../react/ListItemText/index.jsx']
},
{
name: 'Navigation',
Expand Down
4 changes: 0 additions & 4 deletions docs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = {
resolve: {
alias: {
react: 'preact-compat',
'react-dom': 'preact-compat'
},
extensions: ['.jsx', '.js', '.json', '.styl']
},
module: {
Expand Down
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"commitlint-config-cozy": "0.2.2",
"copyfiles": "^1.2.0",
"css-loader": "^0.28.4",
"enzyme": "^3.3.0",
"enzyme-adapter-react-15": "^1.0.5",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
"eslint": "^4.18.2",
"eslint-config-cozy-app": "^0.5.1",
"git-directory-deploy": "^1.5.1",
Expand All @@ -64,11 +64,9 @@
"node-polyglot": "^2.2.2",
"npm-run-all": "^4.0.1",
"postcss-loader": "^2.0.6",
"preact": "^8.1.0",
"preact-compat": "^3.13.1",
"prop-types": "^15.6.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-redux": "^5.0.3",
"react-styleguidist": "7.3.8",
"react-test-renderer": "15.6.1",
Expand All @@ -90,7 +88,6 @@
"md5": "^2.2.0",
"mini-css-extract-plugin": "^0.4.3",
"normalize.css": "^7.0.0",
"preact-portal": "^1.1.2",
"pretty": "^2.0.0",
"react-select": "^2.0.0-beta.6",
"stylus": "^0.54.5"
Expand Down Expand Up @@ -135,6 +132,7 @@
"__ALLOW_HTTP__": false,
"__TARGET__": "browser",
"cozy": {}
}
},
"testURL": "http://localhost/"
}
}
4 changes: 2 additions & 2 deletions react/Alerter/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Portal from 'preact-portal'
import Portal from '../Portal'
import Button from '../Button'

import styles from './styles.styl'
Expand Down Expand Up @@ -34,7 +34,7 @@ class Alert extends Component {

computeDuration() {
const words = this.props.message.split(/\W/).filter(Boolean)
return Math.max(MINIMUM_ALERT_DURATION, words.length / 3 * 1000)
return Math.max(MINIMUM_ALERT_DURATION, (words.length / 3) * 1000)
}

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion react/I18n/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class I18n extends Component {
}
}

componentWillReceiveProps(newProps) {
UNSAFE_componentWillReceiveProps(newProps) {
if (newProps.lang !== this.props.lang) {
this.init(newProps)
}
Expand Down
7 changes: 6 additions & 1 deletion react/IntentHeader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export const IntentHeader = ({ appName, appEditor, appIcon, className }) => (
<div className={classNames(styles['intentHeader'], className)}>
<h1 className={styles['intentHeader-title']}>
<img className={styles['intentHeader-icon']} src={appIcon} />
{appEditor && <span>{appEditor}&nbsp;</span>}
{appEditor && (
<span>
{appEditor}
&nbsp;
</span>
)}
{appName}
</h1>
</div>
Expand Down
9 changes: 6 additions & 3 deletions react/Modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Button } from '../Button'
import Icon from '../Icon'
import migrateProps from '../helpers/migrateProps'
import palette from '../../stylus/settings/palette.json'
import Portal from 'preact-portal'
import Portal from '../Portal'
import uniqueId from 'lodash/uniqueId'
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'

Expand Down Expand Up @@ -40,7 +40,7 @@ class ModalContent extends Component {
}
}

componentWillUpdate(nextProps) {
UNSAFE_componentWillUpdate(nextProps) {
const { children } = nextProps
this.refreshComputedParts(children)
}
Expand Down Expand Up @@ -175,7 +175,10 @@ const ModalHeader = ({
<img className={styles['c-modal-app-icon']} src={appIcon} />
)}
{appEditor && (
<span className={styles['c-app-editor']}>{appEditor}&nbsp;</span>
<span className={styles['c-app-editor']}>
{appEditor}
&nbsp;
</span>
)}
{appName}
</h2>
Expand Down
6 changes: 6 additions & 0 deletions react/Portal/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ReactDOM from 'react-dom'
const Portal = ({ into, children }) => {
const targetElement = document.querySelector(into)
return ReactDOM.createPortal(children, targetElement)
}
export default Portal
2 changes: 1 addition & 1 deletion test/jestsetup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { configure, mount, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-15'
import Adapter from 'enzyme-adapter-react-16'

configure({ adapter: new Adapter() })

Expand Down
Loading

0 comments on commit 84065b1

Please sign in to comment.