小编Den*_*soi的帖子

如何避免客户端使用redux重新提取react-apollo SSR?

我是使用react-appollo的graphql新手我想使用react apollo和redux以及服务器端渲染每件事都很好我的应用程序正在运行但问题是当我的应用程序呈现时它实际上是再次召回api它不使用我的呈现状态..

在此输入图像描述

服务器.js

import express from 'express';
import bodyParser from 'body-parser';

import path from 'path';
import expressGraphQL from 'express-graphql';
import schema from './GraphQL/Schema';
import React from 'react';
import ReactDOMServer from 'react-dom/server'
import { StaticRouter } from 'react-router';
import { ApolloClient, createNetworkInterface, ApolloProvider } from 'react-apollo';
import { getDataFromTree } from "react-apollo"
import store from '../client/Redux/Store/store';

import {serverClient} from './lib/apollo'

require('es6-promise').polyfill();
require('isomorphic-fetch');

import WApp from '../client/App';

//Dev HMR
import HMR from './serverUtils/HMR';

const app = express();
app.use(bodyParser.json());

app.use('/api', expressGraphQL({
    schema,
    graphiql: …
Run Code Online (Sandbox Code Playgroud)

node.js reactjs graphql redux react-apollo

5
推荐指数
1
解决办法
686
查看次数

无法使用 react-native-paper 和 @react-navigation/bottom-tabs 滚动

我有:

<PaperProvider theme={theme}>
  <NavigationContainer>
    <Tab.Navigator initialRouteName="Feed">
      <Tab.Screen
        name="Home"
        component={Conversations}
        options={{
          tabBarLabel: "Home",
          tabBarIcon: ({ color, size }) => (
            <AntDesign name="home" size={size} color={color} />
          ),
        }}
      />
      <Tab.Screen
        name="Explore"
        component={Conversations}
        options={{
          tabBarLabel: "Explore",
          tabBarIcon: ({ color, size }) => (
            <AntDesign name="find" size={size} color={color} />
          ),
        }}
      />
      <Tab.Screen
        name="Profile"
        component={Conversations}
        options={{
          tabBarLabel: "Profile",
          tabBarIcon: ({ color, size }) => (
            <AntDesign name="setting" size={size} color={color} />
          ),
        }}
      />
    </Tab.Navigator>
  </NavigationContainer>
</PaperProvider>;
Run Code Online (Sandbox Code Playgroud)

它加载良好,但我无法滚动。我也在react-native-web尝试使其与网络兼容。

react-native react-navigation expo react-native-paper

5
推荐指数
1
解决办法
809
查看次数

淡入 Bootstrap 3 轮播效果

我正在尝试制作带有淡入淡出效果的旋转木马引导程序,但我对这种效果不是很专业。我想像这样的 css 代码

opacity: 0;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
Run Code Online (Sandbox Code Playgroud)

但我不知道如何在我的代码中应用它。

这是我的旋转木马:

   <div id="myCarousel" class="carousel slide">
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="" contenteditable="false"></li>
        <li data-target="#myCarousel" data-slide-to="1" class="active" contenteditable="false"></li>
        <li data-target="#myCarousel" data-slide-to="2" class="" contenteditable="false"></li>
    </ol>
    <div class="carousel-inner">
        <div class="item" style="">
            <img src="images/slide/slide-1.jpg" alt="" class="" width="3000px" height="800px">
            <div class="carousel-caption">
                <h4 class="">First Slide Title</h4>
                <p class="">
                   Description for First Slide, this First Slide.
                </p>
            </div>
        </div>
        <div class="item active">
            <img src="images/slide/slide-2.jpg" alt="" class="" width="3000px" height="800px">
            <div class="carousel-caption">
                <h4 class="">Second Slide …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery twitter-bootstrap

4
推荐指数
1
解决办法
1万
查看次数

在react.js 中分派操作时如何在 useEffect() 中使用 if/else

我的 redux 相关导入如下 -

来源: https: //github.com/theairbend3r/pokedex

import { useDispatch, useSelector } from "react-redux"

import {
  fetchPokemonNameUrl,
  NUMBER_OF_POKEMON,
  selectorPokemon,
} from "./pokemonCardsSlice"


const dispatch = useDispatch()
const pokemonList = useSelector(selectorPokemon)
Run Code Online (Sandbox Code Playgroud)

我有一个useEffect块如下 -

  useEffect(() => {
    return dispatch(fetchPokemonNameUrl())
  }, [dispatch])
Run Code Online (Sandbox Code Playgroud)

我想做的事 -

 useEffect(() => {
    if (pokemonList.length !== NUMBER_OF_POKEMON) {
      return dispatch(fetchPokemonNameUrl())
    }
  }, [dispatch])
Run Code Online (Sandbox Code Playgroud)

但当我这样做时,我收到警告 -

React Hook useEffect has a missing dependency: 'pokemonList.length'. Either include it or remove the dependency array.eslint(react-hooks/exhaustive-deps)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

javascript reactjs redux react-redux

3
推荐指数
1
解决办法
1946
查看次数

Javascript toFixed()未按预期工作

我正在使用toFixed但该方法无法按预期运行

parseFloat(19373.315).toFixed(2);

//19373.31   Chrome 
Run Code Online (Sandbox Code Playgroud)

预期产出:19373.32

parseFloat(9373.315).toFixed(2);
// 9373.32  Working fine
Run Code Online (Sandbox Code Playgroud)

为什么第一个例子向下舍入,而第二个例子向上舍入?

javascript

2
推荐指数
1
解决办法
116
查看次数

如何使用JSON数据创建CanvasJS图表?

我创建了一个测试图表,它工作正常.我想通过ajax获取我的数据,而不是嵌入网页.我想我需要格式化我的dataPoints数组({ x: new Date(2009, 0), y: 15 },),以便它们可以在外部JSON文件中使用.在我的示例中,填充我的图表的数据格式为:

我的JSChart小提琴示例

{
  name: "File Sharing",
  showInLegend: true,
  type: "stackedColumn100",
  color: "#4192D9 ",
  indexLabel: "{y}",
  dataPoints: [
    { x: new Date(2009, 0), y: 15 },
    { x: new Date(2010, 0), y: 15 },
    { x: new Date(2011, 0), y: 12 },
    { x: new Date(2012, 0), y: 10 },
    { x: new Date(2013, 0), y: 12 },
    { x: new Date(2014, 0), y: 10 }
  ]
},
Run Code Online (Sandbox Code Playgroud)

我查看了Canvas JS站点,他们使用了以下Ajax调用示例:

var dataPoints …
Run Code Online (Sandbox Code Playgroud)

javascript jquery json canvasjs

1
推荐指数
1
解决办法
531
查看次数

如何将tailwindcss添加到vite?

我正在使用vite 0.16.6并希望将 vuepress 站点迁移到使用 vite。

但是我不确定如何配置 vite 以使用 tailwindcss。

在我的 index.css

@tailwind base;
@tailwind components;
@tailwind utilities;

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
Run Code Online (Sandbox Code Playgroud)

vue.js tailwind-css vitejs

0
推荐指数
1
解决办法
3955
查看次数