小编Raj*_*jiv的帖子

删除垫选择的下拉箭头

有没有办法去掉mat-select的箭头?

我需要删除它以使我的选项与标签居中:用箭头选择

angular-material angular

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

React Material UI TextField FormHelperTextProps 样式不起作用

我正在尝试对 Material UI 提供的 TextField 组件附带的帮助程序文本进行样式设置(在此处找到)。我正在使用 FormHelperTextProps(在这里找到)。然而,由于某种原因,我正在编写的样式似乎没有应用于组件本身。如果我能在这方面得到任何帮助,我将不胜感激。这是我的代码:

    const useHelperTextStyles = makeStyles(()=> ({
    root: { 
        "& .MuiFormHelperText-root" : { color: TextFieldColours.error["status-text"] }, 
        // "& .MuiFormHelperText-contained"
    }
    })
     );

    const EmptyTextField = (props: CustomEmptyFieldProps) => {
    const {
         usernameOrPass,
    } = props; 
    const inputLabel = "VolunteerHub " + usernameOrPass; 
    const errorMessage = "Please enter your VolunteerHub " + usernameOrPass; 

    const textFieldStyles = useTextFieldStyles(false);
    const helperTextStyles = useHelperTextStyles(); 
    return (
        <div>
            <TextField
                className={textFieldStyles.root}
                placeholder={inputLabel}
                id="outlined-error-helper-text"
                defaultValue=""
                helperText={errorMessage}
                variant="outlined"
                FormHelperTextProps={{ …
Run Code Online (Sandbox Code Playgroud)

styling uitextfield reactjs material-ui

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

ESLint 错误:“default”被限制用作导出名称

我在 index.js 文件中收到此 eslint 错误:

'default' 被限制用作导出名称 no-restricted-exports

页面/index.js

export { default } from './test';
Run Code Online (Sandbox Code Playgroud)

页面/test.jsx

import React from 'react';

const Test = () => {
  return <div>Test</div>;
};
export default Test;
Run Code Online (Sandbox Code Playgroud)

路线.js

import React from 'react';
import { Switch, Route } from 'react-router-dom';

const testPage = React.lazy(() => import('./page'));

function Routes() {
  return (
    <Switch>
      <Route path="/" exact component={testPage} />
    </Switch>
  );
}
export default Routes;
Run Code Online (Sandbox Code Playgroud)

.eslintrc.json

{
  "env": {
    "browser": true,
    "es2021": true
  },
  "extends": ["plugin:react/recommended", "airbnb"],
  "parserOptions": …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs eslint

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

Material-ui 选项卡 - 我怎样才能滚动它们

我在 AppBar 组件中使用 Material-ui Tablist。问题是我有太多选项卡,我想让它们响应 - 当我的屏幕较小时,其中一些选项卡不可见。

该组件的文档:

https://material-ui.com/components/tabs/

你可以看到当我有这么多标签时它是如何隐藏鞋楦的:

https://codesandbox.io/s/nervous-hoover-809s0?file=/src/App.js

当有其他组件不可见时,是否可以在 AppBar 组件下添加类似滚动条或左右小箭头之类的东西?

可能应该在本节中添加滚动或箭头:

 <AppBar position="static">
            <TabList onChange={handleChange} aria-label="simple tabs example">
              <Tab label="Business Info" value="1" icon={<ContactMailIcon />} />
              <Tab label="Financial" value="2" icon={<MonetizationOnIcon />} />
              <Tab
                label="Participants"
                value="3"
                icon={<AccessibilityIcon />}
              />
              <Tab label="Statistics" value="4" icon={<EqualizerIcon />} />
              <Tab label="Alerts" value="5" icon={<ReportProblemIcon />} />
              <Tab label="Health Care" value="6" icon={<FavoriteIcon />} />
              <Tab label="Plans" value="7" icon={<ListAltIcon />} />
              <Tab
                label="Benchmark"
                value="8"
                icon={<ListAltIcon />}
              />
              <Tab
                label="Heatmap"
                value="9"
                icon={<ListAltIcon />}
              />
              <Tab
                label="Diagnostic" …
Run Code Online (Sandbox Code Playgroud)

javascript css tabs reactjs material-ui

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

React-query 如何在 Jest 测试中从自定义 useMutation 挂钩调用 mutate

我正在运行一个 React Native 项目,在其中测试用 React-query 编写的自定义钩子。我正在使用 Jest、@testing-library/react-hooks 和 @testing-library/react-native。在我的测试中,我似乎找不到调用钩子返回的 mutate 函数的方法。

看一下自定义钩子:

    export default function useAuthentication() {
      const { mutate, data, isSuccess, isError } = useMutation(
        authenticationApi.authenticateUser
      );
      return { mutate, data, isSuccess, isError };
    }
Run Code Online (Sandbox Code Playgroud)

根据react-query的文档,我使用 renderHook() 渲染钩子并等待突变调用的结果:

    const authBody: AuthBody = {
      username: '111111',
      password: '111111',
    };
    
    describe('Authentication Hook', () => {
      const sanityCall = () =>
        axios.post('http://localhost:4000/auth/authenticate');
      console.log(sanityCall());
    
      const queryClient = new QueryClient();
      it('Gets authentication data', async () => {
        const wrapper = ({ children }: any) …
Run Code Online (Sandbox Code Playgroud)

jestjs react-native react-hooks react-native-testing-library react-query

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

Nestjs - 在服务中使用多个模型

我有一个 Nestjs 和 MongoDB 应用程序。

auth.module.ts-

@Module({
  imports: [
    MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]),
  ],
  controllers: [AuthController],
  providers: [AuthService],
})
export class AuthModule {}
Run Code Online (Sandbox Code Playgroud)

auth.service.ts-

@Injectable()
export class AuthService {
  // Inject User model into AuthService
  constructor(@InjectModel(User.name) private userModel: Model<UserDocument>) {}

  getUser(username: string) {
    const user = this.userModel.find({ name: username });
    return user;
  }

  
}
Run Code Online (Sandbox Code Playgroud)

@nestjs/mongoose我使用和创建了一个 UserSchema mongoose

根据文档,当我导入MongooseModule模块中使用的架构时,该架构只能在该特定模块中使用。

如果我想访问我的模块和服务中的多个模型怎么办?有办法吗?

如何将多个模型注入到服务中?

mongoose nestjs nestjs-mongoose

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