你如何摆脱这个className反应选择警告?

时间:2018-06-01 20:12:33

标签: react-select

Warning: the behaviour of 'className' has changed between 2.0.0-beta.2 and 2.0.0-beta.3. You can now use className to specify the class name of the outer container, and classNamePrefix to enable our provided BEM class names for internal elements. The className prop will have no effect on internal elements when 2.0.0 is released.

1 个答案:

答案 0 :(得分:2)

我通过添加 <Select classNamePrefix="foo" {...restOfTheProps} /> 道具摆脱了警告。 import 'package:flutter/material.dart'; void main() => runApp( new MaterialApp( home: new MyApp(), ), ); class MyApp extends StatefulWidget { @override _MyAppState createState() => new _MyAppState(); } class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text("NonstopIO"), ), body: new ListView.builder( itemCount: 5, itemBuilder: (BuildContext context, int index) { return new MyCustomWidget( title: "Title $index", subtitle: "$index", ); }, ), ); } } class MyCustomWidget extends StatefulWidget { final String title; final String subtitle; const MyCustomWidget({Key key, this.title, this.subtitle}) : super(key: key); @override _MyCustomWidgetState createState() => _MyCustomWidgetState(); } class _MyCustomWidgetState extends State<MyCustomWidget> { bool selected = false; @override Widget build(BuildContext context) { return new Card( shape: selected ? new RoundedRectangleBorder( side: new BorderSide(color: Colors.blue, width: 2.0), borderRadius: BorderRadius.circular(4.0)) : new RoundedRectangleBorder( side: new BorderSide(color: Colors.white, width: 2.0), borderRadius: BorderRadius.circular(4.0)), child: new Padding( padding: const EdgeInsets.all(4.0), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text(widget.title), new Text(widget.subtitle), new Checkbox( value: selected, onChanged: (value) { setState(() { selected = value; }); }) ], ), ), ); } }