问题标签 [preact]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
reactjs - 流:解构。React/Preact 中缺少注释
刚刚开始使用 Flow 但似乎无法理解它想让我做什么来添加类型来解构对象,例如道具
IE
抛出一个错误,如
当我添加注释时它仍然抱怨
如果有人能指出,我显然在这里遗漏了一些非常简单的东西吗?
javascript - Preact 生命周期(redux 状态和 componentWillReceiveProps)
我有一个关于 Preact 生命周期的问题。我创建了一个非常接近我的业务用例的 jsfiddle。用例结合了 HOC、redux 和 Preact 生命周期。用例背后的想法很简单!我创建了一个红色的拖动表面,在拖动结束时,我想在减速器中切换一个值!我很惊讶即使mapStateToProps
被调用,当我在下一个componentWillReceiveProps
刻度中记录标志的值时,标志仍然没有切换。以下是来自以下 js fiddle https://jsfiddle.net/4yzLdtkd/32/的日志
component will receive props: isDragging
component will receive props: hasDragged
map state to props false
component will receive props: value = true
component will receive props: value = false
我用 react 创建了完全相同的用例,结果不同。标志是直接切换的。以下是来自以下 js fiddle http://jsfiddle.net/urkuwnLr/9/的日志
component will receive props: isDragging
component will receive props: hasDragged
map state to props false
component will receive props: value = false
这是一个错误还是 Preact 在生命周期方面与 React 的工作方式略有不同?
javascript - 将 UglifyJS 与 Preact、Webpack 2 一起使用时出现意外的令牌错误
我正在使用 Preact/ES6/Webpack 构建一个 Chrome 扩展。我使用 2 种配置之一进行打包:debug
使用 ESLint、Babel 和 CSS + JSON 加载器,prod
添加 2 个插件:UglifyJS
和 Zip。这是webpack.config.js
:
但是当我运行时prod
,我得到以下错误:
值得一提的getLatestResults
是,这并不是我的代码中唯一在await
它前面的函数。此外,它应该只出现在background.js
其他入口点不应该调用它的情况下。
另外值得一提的是,如果我只是对UglifyJS
代码进行注释,生成的压缩扩展名效果很好。
我缺少什么配置来使这些错误消失?
reactjs - React-Router-v4 无法通过 Babel Register 处理 Preact
我正在尝试使用 react-router-4 设置服务器渲染反应。虽然它在前端(Webpack)上工作得很好。在服务器端使用时似乎preact-compat
不起作用。我正在使用babel-register
转换代码。
我这里有一个分支供参考: https ://github.com/abrcenas29/preact-sandbox-v0/tree/wip/isomorphic-react
跑步:
yarn run install
yarn run start:prod
去localhost:3100
javascript - how to create preact-cli custom production build
I'm now studying preact-cli
and so far, it's working though. Problem is when we're gonna build for production, there is zero-configuration for it and found no works for api caching. Is there anyone who has had experience about it, please let me know. Thanks.
reactjs - 反应将类添加到元素
我正在尝试向元素添加类名,但它不起作用。我是否缺少 JSX 组件的某些内容?
reactjs - 如何创建具有 HTMLAttributes 作为道具的组件
我正在使用 Typescript 和 Preact。我想创建一个组件来公开 a<span/>
可以拥有的所有道具:
但是,上面的示例使用了any
,这并不是真正的类型安全。相反,我想公开属性span
。