Skip to content
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

无法使用redux-saga #46

Closed
yz1311 opened this issue Jun 9, 2018 · 7 comments
Closed

无法使用redux-saga #46

yz1311 opened this issue Jun 9, 2018 · 7 comments

Comments

@yz1311
Copy link

yz1311 commented Jun 9, 2018

taro-cli:v0.0.41

redux配置:
`
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk'
import createSagaMiddleware from 'redux-saga'
import rootReducer from '../reducers'
import rootSaga from '../sagas';

const sagaMiddleware = createSagaMiddleware()
let middlewares = [thunk,sagaMiddleware]

export default function configStore () {
const store = createStore(rootReducer, applyMiddleware(...middlewares));
// then run the saga
sagaMiddleware.run(rootSaga);
return store
}
`

运行报错:
image

在对应的dist/npm/redux-saga目录下,发现并没有相关的文件
image

@luckyadam
Copy link
Member

luckyadam commented Jun 9, 2018

0.0.42 修复了 redux-saga 包抽离文件的问题,但是发现运行还是有问题,因为 redux-saga 里存在循环依赖,导致小程序解析错误,目前解决方案是 redux-saga 编译好的文件下载到本地进行使用 这样来使用 import createSagaMiddleware from 'redux-saga/dist/redux-saga'

@yz1311 yz1311 closed this as completed Jun 10, 2018
@yz1311
Copy link
Author

yz1311 commented Jun 12, 2018

集成过程:

1.app.js

//注意,该库的引用必须早于config-store的引用
import '@tarojs/async-await';
import {Provider,connect} from '@tarojs/redux';
import configStore from './store/config-store';

2./store/config-store.js

import { createStore, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga/dist/redux-saga';
import rootReducer from '../reducers';
import rootSaga from '../sagas';

const sagaMiddleware = createSagaMiddleware();
let middlewares = [sagaMiddleware];

export default function configStore () {
const store = createStore(rootReducer, applyMiddleware(...middlewares));
// then run the saga
sagaMiddleware.run(rootSaga);
return store
}

3.需要引用effects的地方

import {effects} from 'redux-saga/dist/redux-saga';
const {all,fork} = effects;

@wkh2
Copy link

wkh2 commented Jul 5, 2018

您好 ,我启动服务的时候出现了这个错误,
ERROR
TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["src"]' and 'exclude' paths were '["tests","node_modules","dist","tests","jest","lib","/*.test.ts","/*.spec.ts"]'.

@luckyadam
Copy link
Member

@wkh2 你好,因为 �H5 的 TS 支持还没完全好,所以建议先使用 js 来开发

@Rychou
Copy link

Rychou commented Feb 20, 2019

@luckyadam 你好,我在集成redux-saga时发现没有这个文件,redux-saga/dist/redux-saga.
版本:redux-saga:^1.0.1

@luowenming
Copy link

-webkit-box-orient: vertical;
这个样式编译成h5就没了?微信小程序是可以的。

@lilywang711
Copy link

@luckyadam 你好,我在集成redux-saga时发现没有这个文件,redux-saga/dist/redux-saga.
版本:redux-saga:^1.0.1

@Rychou 需要降级下 redux-saga 的版本到^0.16.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants