redux

Access State inside of mapDispatchToProps method

陌路散爱 提交于 2020-11-30 02:34:33
问题 I have written a container component using redux and my implementation for mapDispathToProps looks like this const mapDispatchToProps = (dispatch, ownProps) => { return { onChange: (newValue) => { dispatch(updateAttributeSelection('genre', newValue)); dispatch(getTableData(newValue, ownProps.currentYear)); } } } The problem is that in order to getTableData i need the state of some other components. How can I get access to the state object in this method? 回答1: You can use redux-thunk to create

Draft.js - Unable to get data from the database. Cross-origin error

孤人 提交于 2020-11-29 03:38:29
问题 I am trying to use Draft.js in the Blog app I am creating. It all seems fine when saving data to the database and getting it back, just I cannot seem to get createWithContent to work. When I write the following, the data does get saved to the database as I am simply creating an empty editor which then is updated by the user and sent to the database after convertToRaw. const postDetails = useSelector((state) => state.postDetails); const { loading, post, error } = postDetails; const

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

僤鯓⒐⒋嵵緔 提交于 2020-11-28 04:43:04
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

為{幸葍}努か 提交于 2020-11-28 04:39:48
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

送分小仙女□ 提交于 2020-11-28 04:39:44
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/

Getting an error “A non-serializable value was detected in the state” when using redux toolkit - but NOT with normal redux

守給你的承諾、 提交于 2020-11-28 04:39:40
问题 I am trying to switch an app I am building over to use Redux Toolkit, and have noticed this error coming up as soon as I switched over to configureStore from createStore: A non-serializable value was detected in the state, in the path: `varietals.red.0`. Value:, Varietal { "color": "red", "id": "2ada6486-b0b5-520e-b6ac-b91da6f1b901", "isCommon": true, "isSelected": false, "varietal": "bordeaux blend", }, Take a look at the reducer(s) handling this action type: TOGGLE_VARIETAL. (See https:/

Flutter必备开源项目

瘦欲@ 提交于 2020-11-25 11:57:57
首页 动态的展示导航栏的显示和隐藏 日历模块 展示日历的记录, 每日记录生成图片和保存图片 发现 类似朋友圈的内容展示, 图片浏览和保存图片 动态详情模块, 动态的评论和删除评论 多语言国际化 部分页面适配了韩语和英语 颜色主题和暗黑模式 部分页面支持手动的修改项目主题色, 黑色主题(暗黑模式)适配 用到的插件 dio https://pub.dartlang.org/packages/dio Dart社区提供的http请求库,不仅支持常见的网络请求,还支持Restful API、FormData、拦截器、请求取消、Cookie管理、文件上传/下载、超时等操作 provider https://pub.dev/packages/provider Flutter 官方推荐的状态管理插件, 简单的应用状态管理 flutter_redux https://pub.dev/packages/flutter_redux flutter 版的 redux pull_to_refresh https://pub.dev/packages/pull_to_refresh 一个提供上拉加载和下拉刷新的组件,同时支持 Android 和 ios flutter_staggered_grid_view https://pub.dev/packages/flutter_staggered_grid

GraphQL

瘦欲@ 提交于 2020-11-25 03:23:39
感谢支持ayqy个人订阅号,每周义务推送1篇( only unique one )原创精品博文,话题包括但不限于前端、Node、Android、数学(WebGL)、语文(课外书读后感)、英语(文档翻译) 如果觉得弱水三千,一瓢太少,可以去 http://blog.ayqy.net 看个痛快 写在前面 本文第一部分翻译自REST 2.0 Is Here and Its Name Is GraphQL,标题很有视觉冲击力,不小心上钩了 剩余部分是对GraphQL的思考。现在,我们边看译文边汇聚疑问 一.译文 GraphQL是一种API查询语言。虽然与REST有本质区别,但GraphQL可以作为REST的备选项,它提供了高性能、良好的开发体验和一些强大的工具 通过本文,我们来看看怎样用REST和GraphQL来处理一些常见场景。本文附有3个项目,提供了流行电影和演员信息API,还用HTML和jQuery搭了个简单的前端应用,可以查看对应的REST和GraphQL源码 我们将通过这些API来看这两种技术的差异,以便了解其优缺点。开始之前,先布置舞台,快速过一下这些技术是怎么冒出来的 Web早期 Web早期很简单,早期的Web应用就是静态HTML文档。演化到网站想包含存在数据库(例如SQL)里的动态内容,并通过JavaScript来添加交互功能

ES6 对象解构赋值(浅拷贝 VS 深拷贝)

[亡魂溺海] 提交于 2020-11-24 04:38:12
对象的扩展运算符(...)用于取出参数对象的所有可遍历属性,拷贝到当前对象之中。 拷贝对象 let aa = { age: 18, name: 'aaa' } let bb = {...aa}; console.log(bb); // {age: 18, name: "aaa"} 合并对象 扩展运算符(...)可以用于合并两个对象 let aa = { age: 18, name: 'aaa' } let bb = { sex: '男' } let cc = {...aa, ...bb}; // 等同于: // let cc = Object.assign({}, aa, bb); console.log(cc); // {age: 18, name: "aaa", sex: "男"} 拷贝并修改对象 在扩展运算符后面,加上自定义的属性,则扩展运算符内部的同名属性会被覆盖掉。 let aa = { age: 18, name: 'aaa' } let dd = {...aa, name: 'ddd'}; // 等同于: // let dd = {...aa, ...{name: 'ddd'}}; // let dd = Object.assign({}, aa, { name: 'ddd'}); console.log(dd); // {age: 18, name: "ddd"}

[Full-stack] 快速上手开发

谁说我不能喝 提交于 2020-11-24 04:37:45
故事背景 [1] 博客笔记结合《React快速上手开发》再次系统地、全面地走一遍。 [2] React JS Tutorials :包含了JS --> React --> Redux --> Mobx 项目部署 着眼于ful-stack全局,了解前后端的部署,之后才能深刻理解react的角色与位置。 1. 服务器部署 [AWS] Deploy react project on EC2 2. 用户权限管理 [AWS] OAuth2.0 [AWS] User management [AWS] Amazon Cognito 3. 这就是未来后端的趋势 [AWS] Serverless React基本路线 一、静态的html变为了动态生成 React自己的html表达方式 <script> ReactDOM .render( React.DOM . h1 ( { id : "my-heading" }, React.DOM . span ( null , React.DOM . em ( null , "Hell" ), "o" ), " world!" ), document.getElementById( 'app' ) ); </script> 命名冲突:class, for, style <script> ReactDOM.render( /* // COUNTEREXAMPLE