问:
Jetpack Compose - LazyColumn makes an infinite number of recompositions
I want to display a list of items using LazyColumn. I wrote the needed code but when I ran the app I observed that the UI is very laggy. I put some Logs to find out where the problem may be and I discovered that the LazyColumn inifinitely recomposes the items. I replaced the LazyColumn with a Column with scrollable modifier and the problem was gone in this case. But I don't know why LazyColumn behaves like it did.

The list is this:

```<code>var rides = mutableStateListOf<Ride>(Ride(...), Ride(...))
</code>```

A list item is like this:

```<code>@Stable
@Entity(tableName = "ride_table")
data class Ride(
    var img: Bitmap? = null,
    var path: List<List<LatLng>>? = null,
    var cities: List<String>? = null,
    var timeStarted: Long = 0L,
    var timeEnded: Long = 0L,
    var avgSpeedInKmh: Float = 0f,
    var maxSpeedInKmh: Float = 0f,
    var distanceInMeters: Float = 0f,
    var totalTimeInSeconds: Long = 0L,
    @PrimaryKey(autoGenerate = true)
    var id: Long = 0L
) {
    override fun equals(other: Any?): Boolean {
        if(other == null)
            return false
        if(other is Ride) {
            return id == other.id
        } else {
            return false
        }
    }
}
</code>```

The list composable:

```<code>@Composable
fun Rides(rides: List<Ride>) {
    Log.d("RECOMPOSE", "1")
    LazyColumn {
        items(rides) { ride ->
            Log.d("RECOMPOSE", "2")
            RideDetails(ride)
        }
    }
    /*Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
        rides.forEach { ride ->
            Log.d("RECOMPOSE", "2")
            RideDetails(ride)
        }
    }*/
}
</code>```

RideDetails:

```<code>@Composable
fun RideDetails(ride: Ride) {
    Log.d("RECOMPOSE", "3`")
    Text(text = "ride ${ride}")
}
</code>```

Log Recompose 2 gets called non stop in the case of LazyColumn. If I switch to Column this doesn't happen and the number of Log calls is the expected one. What am I doing wrong using LazyColumn?

UPDATE (The below Column gets called inside the setContent that lies in onCreateView)

```<code>Column {

    val cities = rideViewModel.cities
    val filterCities = rideViewModel.filterCities

    val rides = rideViewModel.rides

    TopBar {
        ...
    }

    Chips(cities, filterCities)

    Log.d("RECOMPOSE", "RECOMPOSE INSIDE SCREEN")

    Rides(rides)
}
</code>```

答:
I've just encountered the same problem with a slightly modified code from the Thinking in Compose Article. In my opinion this is a minimal reproducible as requested by @Philip Dukhov

It gets passed a tiny list of 30 items in this case but the counter goes up endlessly. The LazyColumn displays only the 30 items passed though.

I would be very thankful for an explanation.

```<code>class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            SimpleAnimationsTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    var testList = listOf<String>()
                    for(i in 1..30) testList += "Test #$i"
                    ListWithoutBug(myList = testList)
                }
            }
        }
    }
}

@Composable
fun ListWithoutBug(myList: List<String>) { // apparently with bug
    val items = remember { mutableStateOf<Int>(0) }

    Row(horizontalArrangement = Arrangement.SpaceBetween) {
        LazyColumn{
            items(myList) { item ->
                Text("Item: $item")
                items.value++
            }
        }
        Text("Count: ${items.value}")
    }
}
</code>```

Screenshot

Body:
I want to display a list of items using LazyColumn. I wrote the needed code but when I ran the app I observed that the UI is very laggy. I put some Logs to find out where the problem may be and I discovered that the LazyColumn inifinitely recomposes the items. I replaced the LazyColumn with a Column with scrollable modifier and the problem was gone in this case. But I don't know why LazyColumn behaves like it did.

The list is this:

var rides = mutableStateListOf<Ride>(Ride(...), Ride(...))

A list item is like this:

@Stable
@Entity(tableName = "ride_table")
data class Ride(
    var img: Bitmap? = null,
    var path: List<List<LatLng>>? = null,
    var cities: List<String>? = null,
    var timeStarted: Long = 0L,
    var timeEnded: Long = 0L,
    var avgSpeedInKmh: Float = 0f,
    var maxSpeedInKmh: Float = 0f,
    var distanceInMeters: Float = 0f,
    var totalTimeInSeconds: Long = 0L,
    @PrimaryKey(autoGenerate = true)
    var id: Long = 0L
) {
    override fun equals(other: Any?): Boolean {
        if(other == null)
            return false
        if(other is Ride) {
            return id == other.id
        } else {
            return false
        }
    }
}

The list composable:

@Composable
fun Rides(rides: List<Ride>) {
    Log.d("RECOMPOSE", "1")
    LazyColumn {
        items(rides) { ride ->
            Log.d("RECOMPOSE", "2")
            RideDetails(ride)
        }
    }
    /*Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
        rides.forEach { ride ->
            Log.d("RECOMPOSE", "2")
            RideDetails(ride)
        }
    }*/
}

RideDetails:

@Composable
fun RideDetails(ride: Ride) {
    Log.d("RECOMPOSE", "3`")
    Text(text = "ride ${ride}")
}

Log Recompose 2 gets called non stop in the case of LazyColumn. If I switch to Column this doesn't happen and the number of Log calls is the expected one. What am I doing wrong using LazyColumn?

UPDATE (The below Column gets called inside the setContent that lies in onCreateView)

Column {

    val cities = rideViewModel.cities
    val filterCities = rideViewModel.filterCities

    val rides = rideViewModel.rides

    TopBar {
        ...
    }

    Chips(cities, filterCities)

    Log.d("RECOMPOSE", "RECOMPOSE INSIDE SCREEN")

    Rides(rides)
}

Body:
I've just encountered the same problem with a slightly modified code from the Thinking in Compose Article. In my opinion this is a minimal reproducible as requested by @Philip Dukhov

It gets passed a tiny list of 30 items in this case but the counter goes up endlessly. The LazyColumn displays only the 30 items passed though.

I would be very thankful for an explanation.

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            SimpleAnimationsTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    var testList = listOf<String>()
                    for(i in 1..30) testList += "Test #$i"
                    ListWithoutBug(myList = testList)
                }
            }
        }
    }
}

@Composable
fun ListWithoutBug(myList: List<String>) { // apparently with bug
    val items = remember { mutableStateOf<Int>(0) }

    Row(horizontalArrangement = Arrangement.SpaceBetween) {
        LazyColumn{
            items(myList) { item ->
                Text("Item: $item")
                items.value++
            }
        }
        Text("Count: ${items.value}")
    }
}

Screenshot


来源: stackexchange

答:
You can use

([<>])?([0-9]{2})([0-9]{2})(?:([+-])([01])(?!\d{3}\b))?(?:([+-])([0-9]{2})([0-9]{2})(?:([+-])([01])(?!\d{3}\b))?)?
```

See the regex demo. Details:

([<>])? - Group 1 (optional): < or >

([0-9]{2}) - Group 2: two digits

([0-9]{2}) - Group 3: two digits

(?:([+-])([01])(?!\d{3}\b))? - an optional group matching a sequence of:

([+-]) - Group 4: + or -

([01])(?!\d{3}\b) - Group 5: 1 or 0 that are not followed with 3 more digits followed with a word boundary

(?: - start of a non-capturing group:

([+-]) - Group 6: + or -

([0-9]{2}) - Group 7: two digits

([0-9]{2}) - Group 8: two digits

(?:([+-])([01])(?!\d{3}\b))? - Optional sequence of + or - captured in Group 9 and then 1 or 0 (captured in Group 10) that are not followed with 3 more digits followed with a word boundary

)? - end of non-capturing group, repeat 1 or 0 times.

ContentLicense: CC BY-SA 4.0

Title: Regex for time-zones, special case being ignored

Body:
I am creating a regex to parse a string of time zones. The output must be reading input in the following form:

0930

0930+10930-1

<0930

(>0930) (the brackets are just to avoid stack reading this as '<>')

(<0920+1)

(>0920+1)

0920-1240 +1

1200-1-1430

1200-1-1400+1

0920-1240 <<<<<<<<<<<<<<<<<<<<<<<<<ISSUE HERE

The regex cannot differentiate between hhmm-1, and hhmm-hhmm. It will read '0900-1200' as '0900-1'.

I have attempted many variateions of the regex, including:

r'([<>])?([0-9]{2})([0-9]{2})([+-]?)([0-1]?)|([0-9]{2})([0-9]{2})'

r'([<>])?([0-9]{2})([0-9]{2})([+-])?([0-1]?)(([0-1]?{4})()'

r'([<>])?([0-9]{2})([0-9]{2})([+-])?([0-1]?)(?([0-1]?)()'

Currently just considering using 2 different ones! One to test for case of hyphenated time string, the other for the rest,which work for me.
I would like the output in a list of tuples, like

[('', '09', '30', '-', '','12','30', '-', '1'),
 ('', '09', '30', '-', '1','','', '', ''),
 ('>', '09', '30', '-', '1','','', '', '').....]

Body:
You can use

([<>])?([0-9]{2})([0-9]{2})(?:([+-])([01])(?!\d{3}\b))?(?:([+-])([0-9]{2})([0-9]{2})(?:([+-])([01])(?!\d{3}\b))?)?

See the regex demo. Details:

([<>])? - Group 1 (optional): < or >

([0-9]{2}) - Group 2: two digits

([0-9]{2}) - Group 3: two digits

(?:([+-])([01])(?!\d{3}\b))? - an optional group matching a sequence of:

([+-]) - Group 4: + or -

([01])(?!\d{3}\b) - Group 5: 1 or 0 that are not followed with 3 more digits followed with a word boundary

(?: - start of a non-capturing group:

([+-]) - Group 6: + or -

([0-9]{2}) - Group 7: two digits

([0-9]{2}) - Group 8: two digits

(?:([+-])([01])(?!\d{3}\b))? - Optional sequence of + or - captured in Group 9 and then 1 or 0 (captured in Group 10) that are not followed with 3 more digits followed with a word boundary

)? - end of non-capturing group, repeat 1 or 0 times.


问:
Problem with arbitrary values on Tailwind with React
I'm trying to make a react component that changes the width from a parameter but it's doesn't work and I don't know why.

```<code>function Bar() {

    const p =80

    const style = `bg-slate-500 h-8 w-[${p.toFixed(1)}%]`

    console.log(style)

    return (
        <div className=' h-8 w-full'>
            <div className={`bg-slate-500 h-8 w-[${p}%]`}>
            </div>
        </div>
    )
}
export default Bar
</code>```

With this code I get a full-size bar, but if I use a strict String with 80.0 it works fine

答:
The other answers are wrong. In Tailwind V3 JIT is included and you won't need to set mode to jit anymore. And even in Tailwind V2 the posted code wouldn't work.

Following the docs, you must avoid string interpolation and use complete class names.

This is wrong:

```
<p>Instead use <strong>Complete class names</strong>:</p>
<pre class="lang-js prettyprint-override"><code><div class="{{ error ? 'text-red-600' : 'text-green-600' }}"></div>
</code>```

What about using inline styles?

You may be tempted to use inline styles, but remember Content Security Policies are increasingly under scrutiny to disallow unsafe inlines. Any inline style or script could in theory be injected with unintended content. Furthermore, the whole point to Tailwind is to generate CSS at build time, so you'd be working around it and might as well not even be using it in this case.

Body:
I'm trying to make a react component that changes the width from a parameter but it's doesn't work and I don't know why.

function Bar() {

    const p =80

    const style = `bg-slate-500 h-8 w-[${p.toFixed(1)}%]`

    console.log(style)

    return (

            <div className={`bg-slate-500 h-8 w-[${p}%]`}>

    )
}
export default Bar

With this code I get a full-size bar, but if I use a strict String with 80.0 it works fine

Body:
The other answers are wrong. In Tailwind V3 JIT is included and you won't need to set mode to jit anymore. And even in Tailwind V2 the posted code wouldn't work.

Following the docs, you must avoid string interpolation and use complete class names.

This is wrong:

<div class="text-{{ error ? 'red' : 'green' }}-600"></div>

Instead use Complete class names:

<div class="{{ error ? 'text-red-600' : 'text-green-600' }}"></div>

What about using inline styles?

You may be tempted to use inline styles, but remember Content Security Policies are increasingly under scrutiny to disallow unsafe inlines. Any inline style or script could in theory be injected with unintended content. Furthermore, the whole point to Tailwind is to generate CSS at build time, so you'd be working around it and might as well not even be using it in this case.


问:
How can I use Python 2 on Google Colab?
How can I use the earlier version of Python i.e version 2.x?

Under the 'change runtime' option - I can see the option for selecting hardware accelerator.

答:
If you are running some python program, you can use
!python2.7 your_program.py instead of !python your_program.py

But if you want to execute some python2.7 code, I think that as mentioned in the previous answers, it is not possible.

Title: How can I use Python 2 on Google Colab?


问:
Laravel 8 Custom Login With Custom Model
Greetings to all I have a problem with my Laravel 8 code I'm getting
"ErrorException Undefined index: password" from vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:159

I use custom model and I set up in config/auth.php to use my Client model not a User model and when I try Auth::attempt($credentials) it's failed and give me that error here is my code

Client.php Model

```<code><?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Client extends Authenticatable
{
    use HasFactory;

    protected $table = 'clients';
    protected $primaryKey = 'client_id';
    public $incrementing = true;

    protected $fillable = ['client_firstName', 'client_lastName', 'client_email', 'client_phoneNumber', 'client_password', 'client_isAdmin', 'client_created_at', 'client_updated_at'];

    public $timestamps = true;
    const CREATED_AT = 'client_created_at';
    const UPDATED_AT = 'client_updated_at';
}
</code>```

config/auth.php

```<code> 'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\Client::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],
</code>```

ClientController.php

```<code>public function signIn(Request $request){
       if($request->isMethod('POST')){
            $validator = Validator::make($request->all(), [
                'signin_email' => 'required|string|email:rfc,dns|bail',
                'signin_password' => 'required|string|bail',
            ], [
                'signin_email.required' => 'The email address field is required.',
                'signin_email.email' => 'You must provide an a valid email address.',
                'signin_password.required' => 'The password field is required.',
            ]);

            if($validator->fails()) {
                return redirect()->back()->withErrors($validator)->withInput();
            }else{
                $credentials = [
                    'client_email' => $request->signin_email,
                    'client_password' => $request->signin_password,
                ];

                if(Auth::attempt($credentials)) {
                    return redirect()->to('dashboard');
                }else{
                    return redirect()->back()->withErrors("Sorry, the passed email address or password is incorrect, try again!")->withInput();
                }
            }
       }else{
           return view('signIn');
       }
    }
</code>```

答:
I have found a solution I will need to add to my model getAuthPassword, also I need to change app/auth.php and ClientController.php

Client.php Model

```<code><?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Client extends Authenticatable
{
    use HasFactory;

    protected $table = 'clients';
    protected $primaryKey = 'client_id';
    public $incrementing = true;

    protected $fillable = ['client_firstName', 'client_lastName', 'client_email', 'client_phoneNumber', 'client_password', 'client_isAdmin', 'client_created_at', 'client_updated_at'];

    public $timestamps = true;
    const CREATED_AT = 'client_created_at';
    const UPDATED_AT = 'client_updated_at';

    public function getAuthPassword(){
        return $this->client_password;
    }
}
</code>```

app/auth.php

```<code><?php

return [

    /*
    |--------------------------------------------------------------------------
    | Authentication Defaults
    |--------------------------------------------------------------------------
    |
    | This option controls the default authentication "guard" and password
    | reset options for your application. You may change these defaults
    | as required, but they're a perfect start for most applications.
    |
    */

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'clients',
    ],

    /*
    |--------------------------------------------------------------------------
    | Authentication Guards
    |--------------------------------------------------------------------------
    |
    | Next, you may define every authentication guard for your application.
    | Of course, a great default configuration has been defined for you
    | here which uses session storage and the Eloquent user provider.
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | Supported: "session"
    |
    */

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'clients',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | User Providers
    |--------------------------------------------------------------------------
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | If you have multiple user tables or models you may configure multiple
    | sources which represent each model / table. These sources may then
    | be assigned to any extra authentication guards you have defined.
    |
    | Supported: "database", "eloquent"
    |
    */

    'providers' => [
        'clients' => [
            'driver' => 'eloquent',
            'model' => App\Models\Client::class,
            'table' => 'clients',
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Resetting Passwords
    |--------------------------------------------------------------------------
    |
    | You may specify multiple password reset configurations if you have more
    | than one user table or model in the application and you want to have
    | separate password reset settings based on the specific user types.
    |
    | The expire time is the number of minutes that the reset token should be
    | considered valid. This security feature keeps tokens short-lived so
    | they have less time to be guessed. You may change this as needed.
    |
    */

    'passwords' => [
        'clients' => [
            'provider' => 'clients',
            'table' => 'clients',
            'expire' => 60,
            'throttle' => 60,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Password Confirmation Timeout
    |--------------------------------------------------------------------------
    |
    | Here you may define the amount of seconds before a password confirmation
    | times out and the user is prompted to re-enter their password via the
    | confirmation screen. By default, the timeout lasts for three hours.
    |
    */

    'password_timeout' => 10800,

];
</code>```

ClientController.php

```<code>public function signIn(Request $request){
       if($request->isMethod('POST')){
            $validator = Validator::make($request->all(), [
                'signin_email' => 'required|string|email:rfc,dns|bail',
                'signin_password' => 'required|string|bail',
            ], [
                'signin_email.required' => 'The email address field is required.',
                'signin_email.email' => 'You must provide an a valid email address.',
                'signin_password.required' => 'The password field is required.',
            ]);

            if($validator->fails()) {
                return redirect()->back()->withErrors($validator)->withInput();
            }else{
                $credentials = [
                    'client_email' => $request->signin_email,
                    'password' => $request->signin_password,
                ];

                if(Auth::attempt($credentials)) {
                    return redirect()->to('dashboard');
                }else{
                    return redirect()->back()->withErrors("Sorry, the passed email address or password is incorrect, try again!")->withInput();
                }
            }
       }else{
           return view('signIn');
       }
    }
</code>```

Body:
Greetings to all I have a problem with my Laravel 8 code I'm getting
"ErrorException Undefined index: password" from vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:159

I use custom model and I set up in config/auth.php to use my Client model not a User model and when I try Auth::attempt($credentials) it's failed and give me that error here is my code

Client.php Model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Client extends Authenticatable
{
    use HasFactory;

    protected $table = 'clients';
    protected $primaryKey = 'client_id';
    public $incrementing = true;

    protected $fillable = ['client_firstName', 'client_lastName', 'client_email', 'client_phoneNumber', 'client_password', 'client_isAdmin', 'client_created_at', 'client_updated_at'];

    public $timestamps = true;
    const CREATED_AT = 'client_created_at';
    const UPDATED_AT = 'client_updated_at';
}

config/auth.php

 'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\Client::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

ClientController.php

public function signIn(Request $request){
       if($request->isMethod('POST')){
            $validator = Validator::make($request->all(), [
                'signin_email' => 'required|string|email:rfc,dns|bail',
                'signin_password' => 'required|string|bail',
            ], [
                'signin_email.required' => 'The email address field is required.',
                'signin_email.email' => 'You must provide an a valid email address.',
                'signin_password.required' => 'The password field is required.',
            ]);

            if($validator->fails()) {
                return redirect()->back()->withErrors($validator)->withInput();
            }else{
                $credentials = [
                    'client_email' => $request->signin_email,
                    'client_password' => $request->signin_password,
                ];

                if(Auth::attempt($credentials)) {
                    return redirect()->to('dashboard');
                }else{
                    return redirect()->back()->withErrors("Sorry, the passed email address or password is incorrect, try again!")->withInput();
                }
            }
       }else{
           return view('signIn');
       }
    }

Body:
I have found a solution I will need to add to my model getAuthPassword, also I need to change app/auth.php and ClientController.php

Client.php Model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Client extends Authenticatable
{
    use HasFactory;

    protected $table = 'clients';
    protected $primaryKey = 'client_id';
    public $incrementing = true;

    protected $fillable = ['client_firstName', 'client_lastName', 'client_email', 'client_phoneNumber', 'client_password', 'client_isAdmin', 'client_created_at', 'client_updated_at'];

    public $timestamps = true;
    const CREATED_AT = 'client_created_at';
    const UPDATED_AT = 'client_updated_at';

    public function getAuthPassword(){
        return $this->client_password;
    }
}

app/auth.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Authentication Defaults
    |--------------------------------------------------------------------------
    |
    | This option controls the default authentication "guard" and password
    | reset options for your application. You may change these defaults
    | as required, but they're a perfect start for most applications.
    |
    */

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'clients',
    ],

    /*
    |--------------------------------------------------------------------------
    | Authentication Guards
    |--------------------------------------------------------------------------
    |
    | Next, you may define every authentication guard for your application.
    | Of course, a great default configuration has been defined for you
    | here which uses session storage and the Eloquent user provider.
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | Supported: "session"
    |
    */

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'clients',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | User Providers
    |--------------------------------------------------------------------------
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | If you have multiple user tables or models you may configure multiple
    | sources which represent each model / table. These sources may then
    | be assigned to any extra authentication guards you have defined.
    |
    | Supported: "database", "eloquent"
    |
    */

    'providers' => [
        'clients' => [
            'driver' => 'eloquent',
            'model' => App\Models\Client::class,
            'table' => 'clients',
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Resetting Passwords
    |--------------------------------------------------------------------------
    |
    | You may specify multiple password reset configurations if you have more
    | than one user table or model in the application and you want to have
    | separate password reset settings based on the specific user types.
    |
    | The expire time is the number of minutes that the reset token should be
    | considered valid. This security feature keeps tokens short-lived so
    | they have less time to be guessed. You may change this as needed.
    |
    */

    'passwords' => [
        'clients' => [
            'provider' => 'clients',
            'table' => 'clients',
            'expire' => 60,
            'throttle' => 60,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Password Confirmation Timeout
    |--------------------------------------------------------------------------
    |
    | Here you may define the amount of seconds before a password confirmation
    | times out and the user is prompted to re-enter their password via the
    | confirmation screen. By default, the timeout lasts for three hours.
    |
    */

    'password_timeout' => 10800,

];

ClientController.php

public function signIn(Request $request){
       if($request->isMethod('POST')){
            $validator = Validator::make($request->all(), [
                'signin_email' => 'required|string|email:rfc,dns|bail',
                'signin_password' => 'required|string|bail',
            ], [
                'signin_email.required' => 'The email address field is required.',
                'signin_email.email' => 'You must provide an a valid email address.',
                'signin_password.required' => 'The password field is required.',
            ]);

            if($validator->fails()) {
                return redirect()->back()->withErrors($validator)->withInput();
            }else{
                $credentials = [
                    'client_email' => $request->signin_email,
                    'password' => $request->signin_password,
                ];

                if(Auth::attempt($credentials)) {
                    return redirect()->to('dashboard');
                }else{
                    return redirect()->back()->withErrors("Sorry, the passed email address or password is incorrect, try again!")->withInput();
                }
            }
       }else{
           return view('signIn');
       }
    }


问:
zsh fzf search path is strange on Mac
I installed fzf for the zsh on my Mac

I usecd ** <Tab> , instead of getting a list of directories which can get into

I always get a long list of directories,such as

How to solve this problem?

when I search specific file, it always return a list of library container files of Mac file system, how to ignore them and just leave the real one.
it takes a very long time to get the top1 real result

BTW the first line numbers  seems going infinite, why is that.

答:
fzf default command search every files in your home diretory and follow every symbol links e.g. ~/Library/Container/*/Downloads which return files multi times.

According to the readme of fzf, you can specify FZF_DEFAULT_COMMAND and _fzf_compgen_path() _fzf_compgen_dir() to exclude directories what you don't want to see.

# Use fd (https://github.com/sharkdp/fd) instead of the default find

# remove -L of fzf default command
# export FZF_DEFAULT_COMMAND="find . -mindepth 1 -path '*/\.*\' -prune -o -type f -print -o -type l -print 2> /dev/null | cut -b3-"
export FZF_DEFAULT_COMMAND='fd --type f'

_fzf_compgen_path() {
  fd --hidden --follow --exclude ".git" . "$1"
}

# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
  fd --type d --hidden --follow --exclude ".git" . "$1"
}
```

Title: zsh fzf search path is strange on Mac


问:
SCM Manager returning 404 error when I try to restart scm from console
Goodevening Stackoverflow,

Today I upgraded scm from version 1.60 to 2.30 only that it returns a 404 error from Google console (the browser just keeps loading until the request times out).

running journalctl -u scm-server returning the following error:

```<code>Exception in thread "ScmEventBus-1-0" java.lang.UnsatisfiedLinkError: /tmp/jna6511840250923886855.tmp: /tmp/jna6511840250923886855.tmp: failed to map segment from shared object`
at java.lang.ClassLoader$NativeLibrary.load(Native Method)`
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
at java.lang.Runtime.load0(Runtime.java:810)
at java.lang.System.load(System.java:1088)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
at com.sun.jna.Native.<clinit>(Native.java:195)
at com.sun.akuma.CLibrary.<clinit>(CLibrary.java:89)
at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:128)
at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:116)
at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:104)
at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:92)
at sonia.scm.lifecycle.PosixRestartStrategy.restart(PosixRestartStrategy.java:57)
at sonia.scm.lifecycle.PosixRestartStrategy.executeRestart(PosixRestartStrategy.java:47)
at sonia.scm.lifecycle.RestartStrategy.restart(RestartStrategy.java:67)
at sonia.scm.lifecycle.BootstrapContextFilter.handleRestartEvent(BootstrapContextFilter.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.github.legman.InvocationContext.invoke(InvocationContext.java:108)
at com.github.legman.InvocationContext.proceed(InvocationContext.java:101)
at com.github.legman.micrometer.MicrometerInvocationInterceptor.invoke(MicrometerInvocationInterceptor.java:47)
at com.github.legman.InvocationContext.proceed(InvocationContext.java:99)
at com.github.legman.EventHandler.handleEvent(EventHandler.java:103)
at com.github.legman.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:52)
at com.github.legman.EventBus.dispatchSynchronous(EventBus.java:452)
at com.github.legman.EventBus.lambda$dispatch$1(EventBus.java:444)
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120)
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)`*
</code>```

From google chrome console I get the following error:

```<code>GET http://serverip/scm/api/v2/ 404 (Not Found) ApiClient.request @ apiclient.ts?718f:307
</code>```

If I force restart from the server with service scm-server restart, scm manager returns up and running, and with the plugin installed.

Now it seems like the browser is finding it difficult to successfully restart SCM service even if in scm-manager.log I can see the jvm service was restarted.

I also checked the apache log error_log and found an error as follows:

```<code>[proxy:error] [pid 32822] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed
[proxy_http:error] [pid 32822] [client 10.12.173.165:62193] AH01114: HTTP: failed to make connection to backend: localhost
[proxy:error] [pid 32821] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed
</code>```

The thing is with version 1.60 I never got any of these errors, the reverse proxy settings in httpd.conf works until this restart from console activity.

I really apologise for the long story, I am only trying to make it comprehensive as much as possibile.

Thanks to anyone willing to help a brother.

Regards

答:
This problem occurs because your scm-manager restart accesses the tmp folder where it has no right to execute. This issue with jna is known by the SCM-Manager team and will be fixed soon.

As workaround try: After installation, run chmod -R 775 scm and scm should be able to restart service from browser

Body:
Goodevening Stackoverflow,

Today I upgraded scm from version 1.60 to 2.30 only that it returns a 404 error from Google console (the browser just keeps loading until the request times out).

running journalctl -u scm-server returning the following error:

Exception in thread "ScmEventBus-1-0" java.lang.UnsatisfiedLinkError: /tmp/jna6511840250923886855.tmp: /tmp/jna6511840250923886855.tmp: failed to map segment from shared object`
at java.lang.ClassLoader$NativeLibrary.load(Native Method)`
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
at java.lang.Runtime.load0(Runtime.java:810)
at java.lang.System.load(System.java:1088)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
at com.sun.jna.Native.<clinit>(Native.java:195)
at com.sun.akuma.CLibrary.<clinit>(CLibrary.java:89)
at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:128)
at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:116)
at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:104)
at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:92)
at sonia.scm.lifecycle.PosixRestartStrategy.restart(PosixRestartStrategy.java:57)
at sonia.scm.lifecycle.PosixRestartStrategy.executeRestart(PosixRestartStrategy.java:47)
at sonia.scm.lifecycle.RestartStrategy.restart(RestartStrategy.java:67)
at sonia.scm.lifecycle.BootstrapContextFilter.handleRestartEvent(BootstrapContextFilter.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.github.legman.InvocationContext.invoke(InvocationContext.java:108)
at com.github.legman.InvocationContext.proceed(InvocationContext.java:101)
at com.github.legman.micrometer.MicrometerInvocationInterceptor.invoke(MicrometerInvocationInterceptor.java:47)
at com.github.legman.InvocationContext.proceed(InvocationContext.java:99)
at com.github.legman.EventHandler.handleEvent(EventHandler.java:103)
at com.github.legman.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:52)
at com.github.legman.EventBus.dispatchSynchronous(EventBus.java:452)
at com.github.legman.EventBus.lambda$dispatch$1(EventBus.java:444)
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120)
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)`*

From google chrome console I get the following error:

GET http://serverip/scm/api/v2/ 404 (Not Found) ApiClient.request @ apiclient.ts?718f:307

If I force restart from the server with service scm-server restart, scm manager returns up and running, and with the plugin installed.

Now it seems like the browser is finding it difficult to successfully restart SCM service even if in scm-manager.log I can see the jvm service was restarted.

I also checked the apache log error_log and found an error as follows:

[proxy:error] [pid 32822] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed
[proxy_http:error] [pid 32822] [client 10.12.173.165:62193] AH01114: HTTP: failed to make connection to backend: localhost
[proxy:error] [pid 32821] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8080 (localhost) failed

The thing is with version 1.60 I never got any of these errors, the reverse proxy settings in httpd.conf works until this restart from console activity.

I really apologise for the long story, I am only trying to make it comprehensive as much as possibile.

Thanks to anyone willing to help a brother.

Regards


问:
Sweep Algorithm
Who can recommend me a good sweep algorithm which would have good results for double data?
Some documentation, methods, anything.

This is a sweep algorithm for detecting the intersection points of a graph in the 2-dimensional space. The graph is always closed.

答:
The one in http://www.amazon.com/Computational-Geometry-Algorithms-Applications-Second/dp/3540656200 is pretty good.

The sweepline for testing intersections is pretty straightforward, though. Here's a paper to get you started: http://www.cs.umd.edu/~mount/Papers/crc-intersect.pdf.

OwnerDisplayName: madalina

ContentLicense: CC BY-SA 2.5

Title: Sweep Algorithm

LastEditorDisplayName: mmyers

OwnerDisplayName: codekaizen


问:
404 error for Google +1 button in web pages
Hi I am new web development and php coding.I have implemented the google +1 for my web site, but when I clicked on it, it is showing error message "404. That’s an error.The requested URL was not found on this server. That’s all we know". I am using the code that is provided in following http://www.google.com/webmasters/+1/button/</p>

答: Did you really put whatever you wanted the +1-button for inside the tags? A 404 would suggest that you just left the tags as they appear in the example. If you were to supply some sample code of whatever is now working, people on this site could help you out a lot better.</p>

ContentLicense: CC BY-SA 3.0


问:
FreeRTOS can't set isr routine as critical region
I am running FreeRTOS on a nrf52840

I have 2 interrupts running and my RTOS crashes if I enter in an interrupt while in another one
To avoid such case I added the critical region functions, I also added debug pins to see time spent in the two irqs

```<code>void my_irq (void)
{
    BaseType_t xHigherPriorityTaskWoken;
    UBaseType_t uxSavedInterruptStatus;
    uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
    d_set_pin();
    xHigherPriorityTaskWoken = pdFALSE;

    /* some code */

    vTaskNotifyGiveFromISR(acq->task.handler, &xHigherPriorityTaskWoken);

    portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

    d_clear_pin();
    taskEXIT_CRITICAL_FROM_ISR(uxSavedInterruptStatus);
}
</code>```

It did not work so I tried disabling interrupts :

```<code>void my_irq (void)
{
    BaseType_t xHigherPriorityTaskWoken;
    taskDISABLE_INTERRUPTS();
    d_set_pin();
    xHigherPriorityTaskWoken = pdFALSE;

    /* some code */

    vTaskNotifyGiveFromISR(acq->task.handler, &xHigherPriorityTaskWoken);

    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);

    d_clear_pin();
    taskENABLE_INTERRUPTS();
}
</code>```

But still I get this and it crashes :

Do you have any ideas why my MCU leaves the interrupt routine ?

答:
Your MCU is built around ARM Cortex-M4F kernel. I'm sorry, you didn't mention this in your question, did you set interrupt priorities correctly, according to this: https://www.freertos.org/RTOS-Cortex-M3-M4.html ?

Also I've found that you can't call FreeRTOS API functions from within critical section in the ISR. See this: https://www.freertos.org/taskENTER_CRITICAL_FROM_ISR_taskEXIT_CRITICAL_FROM_ISR.html

I'm sorry again if you've already checked these moments.

Body:
I am running FreeRTOS on a nrf52840

I have 2 interrupts running and my RTOS crashes if I enter in an interrupt while in another one
To avoid such case I added the critical region functions, I also added debug pins to see time spent in the two irqs

void my_irq (void)
{
    BaseType_t xHigherPriorityTaskWoken;
    UBaseType_t uxSavedInterruptStatus;
    uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
    d_set_pin();
    xHigherPriorityTaskWoken = pdFALSE;

    /* some code */

    vTaskNotifyGiveFromISR(acq->task.handler, &xHigherPriorityTaskWoken);

    portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

    d_clear_pin();
    taskEXIT_CRITICAL_FROM_ISR(uxSavedInterruptStatus);
}

It did not work so I tried disabling interrupts :

void my_irq (void)
{
    BaseType_t xHigherPriorityTaskWoken;
    taskDISABLE_INTERRUPTS();
    d_set_pin();
    xHigherPriorityTaskWoken = pdFALSE;

    /* some code */

    vTaskNotifyGiveFromISR(acq->task.handler, &xHigherPriorityTaskWoken);

    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);

    d_clear_pin();
    taskENABLE_INTERRUPTS();
}

But still I get this and it crashes :

Do you have any ideas why my MCU leaves the interrupt routine ?


问:
Convert $objectToArray map element to String
I have a collection in database that I am trying to retrieve some data from it , the query is working fine when $orderID has string elements , but is failing when $orderID has some numbers in array , and it is throwing

```<code>query failed: (Location40395) PlanExecutor error during aggregation :: caused by :: $arrayToObject requires an array of key-value pairs, where the key must be of type string. Found key type: double
</code>```

I think there must be some old data when we were saving orderID as a number so that is why it is failing from some range of dates

Query

```<code>{
    "Order_Details": {
        "$map": {
            "input": {
                "$objectToArray": {
                    "$arrayToObject": {
                        "$zip": {
                            "inputs": [
                                "$orderID",
                                "$total_value_of_order"
                            ]
                        }
                    }
                }
            },
            "as": "el",
            "in": {
                "orderID": "$$el.k",
                "total_value_of_order": "$$el.v"
            }
        }
    }
}
</code>```

I am trying to typecast el.k to string I am using  $toString but can't seem to work , the way I am trying it is

```<code>{
    "as": "el",
    "in": {
        "orderID": {
            "$toString": "$$el.k"
        },
        "total_value_of_order": "$$el.v"
    }
}
</code>```

Example collection

```<code>[
  {
    "_id": ObjectId("5e529ee5f8647eb59e5620a2"),
    "visitID": "dVmy7flXFHzzkn9HiMt8IoWvthoTZW",
    "date": ISODate("2022-02-08T16:29:13.413Z"),
    "control": true,
    "orderID": [
      122343242
    ],
    "target": "test",
    "total_value_of_order": [
      60
    ]
  }
]
</code>```

答:
You are close, the approach is fine. you just have a couple of syntax issues.
The major thing that needs to change is the input for $arrayToObject, currently your input looks like this:

```<code>[[number, number], [number, number]]
</code>```

However $arrayToObject expects input in a certain format:

```<code>[{k: string, v: value}]
</code>```

So this it what we'll add, like so:

```<code>db.collection.aggregate([
  {
    $project: {
      "Order_Details": {
        "$map": {
          "input": {
            "$objectToArray": {
              "$arrayToObject": {
                $map: {
                  input: {
                    "$zip": {
                      "inputs": [
                        "$orderID",
                        "$total_value_of_order"
                      ]
                    }
                  },
                  in: {
                    k: {
                      $toString: {
                        "$arrayElemAt": [
                          "$$this",
                          0
                        ]
                      }
                    },
                    v: {
                      "$arrayElemAt": [
                        "$$this",
                        1
                      ]
                    }
                  }
                }
              }
            }
          },
          "as": "el",
          "in": {
            "orderID": "$$el.v",
            "total_value_of_order": "$$el.k"
          }
        }
      }
    }
  }
])
</code>```

Mongo Playground

Notice the "orderid" format changes to string which affects it's structure, I recommend just switching between the k and v in the pipeline, like this

Body:
I have a collection in database that I am trying to retrieve some data from it , the query is working fine when $orderID has string elements , but is failing when $orderID has some numbers in array , and it is throwing

query failed: (Location40395) PlanExecutor error during aggregation :: caused by :: $arrayToObject requires an array of key-value pairs, where the key must be of type string. Found key type: double

I think there must be some old data when we were saving orderID as a number so that is why it is failing from some range of dates

Query

{
    "Order_Details": {
        "$map": {
            "input": {
                "$objectToArray": {
                    "$arrayToObject": {
                        "$zip": {
                            "inputs": [
                                "$orderID",
                                "$total_value_of_order"
                            ]
                        }
                    }
                }
            },
            "as": "el",
            "in": {
                "orderID": "$$el.k",
                "total_value_of_order": "$$el.v"
            }
        }
    }
}

I am trying to typecast el.k to string I am using  $toString but can't seem to work , the way I am trying it is

{
    "as": "el",
    "in": {
        "orderID": {
            "$toString": "$$el.k"
        },
        "total_value_of_order": "$$el.v"
    }
}

Example collection

[
  {
    "_id": ObjectId("5e529ee5f8647eb59e5620a2"),
    "visitID": "dVmy7flXFHzzkn9HiMt8IoWvthoTZW",
    "date": ISODate("2022-02-08T16:29:13.413Z"),
    "control": true,
    "orderID": [
      122343242
    ],
    "target": "test",
    "total_value_of_order": [
      60
    ]
  }
]

Body:
You are close, the approach is fine. you just have a couple of syntax issues.
The major thing that needs to change is the input for $arrayToObject, currently your input looks like this:

[[number, number], [number, number]]

However $arrayToObject expects input in a certain format:

[{k: string, v: value}]

So this it what we'll add, like so:

db.collection.aggregate([
  {
    $project: {
      "Order_Details": {
        "$map": {
          "input": {
            "$objectToArray": {
              "$arrayToObject": {
                $map: {
                  input: {
                    "$zip": {
                      "inputs": [
                        "$orderID",
                        "$total_value_of_order"
                      ]
                    }
                  },
                  in: {
                    k: {
                      $toString: {
                        "$arrayElemAt": [
                          "$$this",
                          0
                        ]
                      }
                    },
                    v: {
                      "$arrayElemAt": [
                        "$$this",
                        1
                      ]
                    }
                  }
                }
              }
            }
          },
          "as": "el",
          "in": {
            "orderID": "$$el.v",
            "total_value_of_order": "$$el.k"
          }
        }
      }
    }
  }
])

Mongo Playground

Notice the "orderid" format changes to string which affects it's structure, I recommend just switching between the k and v in the pipeline, like this


问:
Problem with grouping
I have the following code (DevExpress component):

```<code>dgvDisplayDictionary.DataSource = DataAccessor.GetAllRecords();

gvDisplay.BeginSort();
gvDisplay.ClearGrouping();
gvDisplay.Columns[0].GroupInterval = ColumnGroupInterval.Alphabetical;
gvDisplay.Columns[0].GroupIndex = 0;
gvDisplay.EndSort();
</code>```

I get the following error:

```<code>At least one object must implement IComparable.
</code>```

My class binding to gvDisplay:

```<code>public class NormDocCost:AbstractDisplayDictionary.
    {
        public virtual Category Category { get; set; }
        public virtual DocumentFormat DocumentFormat { get; set; }
        public virtual Translate Translate { get; set; }
        public virtual int NdcId { get; set; }
        public virtual int PageStart { get; set; }
        public virtual int PageEnd { get; set; }
        public virtual double Cost { get; set; }
        public virtual DateTime? DateFrom { get; set; }
        public virtual DateTime? DateTo { get; set; }
   }
</code>```

I have trying to write this code, but not works:

```<code>public int CompareTo(object other)
        {
            var obj = (NormDocCost)other;
            if(obj.Category.Id == Category.Id)
            {
                return this.Category.NameRu.CompareTo(obj.Category.NameRu);
            }
            return obj.Category.Id.CompareTo(Category.Id);
        }
</code>```

答: When the grid groups records, it first sorts them and then only create groups based on the rows with the same values in group columns.  So, I tend to think that the first column is bound to the Categbory field.  What is the type of it?  I think that the grid cannot compare values of this field and thus this exception is raised.</p>

Title: Problem with grouping

Body:
I have the following code (DevExpress component):

dgvDisplayDictionary.DataSource = DataAccessor.GetAllRecords();

gvDisplay.BeginSort();
gvDisplay.ClearGrouping();
gvDisplay.Columns[0].GroupInterval = ColumnGroupInterval.Alphabetical;
gvDisplay.Columns[0].GroupIndex = 0;
gvDisplay.EndSort();

I get the following error:

At least one object must implement IComparable.

My class binding to gvDisplay:

public class NormDocCost:AbstractDisplayDictionary.
    {
        public virtual Category Category { get; set; }
        public virtual DocumentFormat DocumentFormat { get; set; }
        public virtual Translate Translate { get; set; }
        public virtual int NdcId { get; set; }
        public virtual int PageStart { get; set; }
        public virtual int PageEnd { get; set; }
        public virtual double Cost { get; set; }
        public virtual DateTime? DateFrom { get; set; }
        public virtual DateTime? DateTo { get; set; }
   }

I have trying to write this code, but not works:

public int CompareTo(object other)
        {
            var obj = (NormDocCost)other;
            if(obj.Category.Id == Category.Id)
            {
                return this.Category.NameRu.CompareTo(obj.Category.NameRu);
            }
            return obj.Category.Id.CompareTo(Category.Id);
        }


问:
How to open emulators in different windows at Android Studio (Bumblebee | 2021.1.1)?
I have two running emulators but they open together in different tabs and in one single window.

How to open them in two different window?

Android Studio Bumblebee | 2021.1.1
Build #AI-211.7628.21.2111.8092744, built on January 19, 2022
Runtime version: 11.0.11+0-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-96-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 3072M
Cores: 12
Registry: external.system.auto.import.disabled=true, debugger.watches.in.variables=false
Non-Bundled Plugins: JUnit4-Parallel-Runner (1.5), com.intellij.javafx (1.0.3), com.intellij.marketplace (211.7628.36), com.atlassian.bitbucket.references (2021.1.195), com.thoughtworks.gauge (211.6693.111), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), com.developerphil.adbidea (1.6.4)
Current Desktop: ubuntu:GNOME
```

答:
For Mac OS you can navigate as follow.

Android Studio > Preferences > Tools > Emulator and deselect Launch in a tool window.

Official Ref : https://developer.android.com/studio/run/emulator#run-emulator-studio


问:
Switching Toggle State On Page Appearing
Xamarin doesn't seem to natively support commanding a switch. In my app, apon a page opening, the app scans a device and looks at a certain value. Depending on whether or not the value is 0 or 1 I'd like to set the state of the switch accordingly.

I'd like it to determine and change state inside of:

```<code>protected async override void OnAppearing()
</code>```

On Xaml page I have:

```<code><Switch Grid.Column="3" Grid.Row="2" IsToggled ="{Binding OnToggledCutouts, Mode=TwoWay}" Toggled="OnToggledCutout" x:Name="ToggleCutouts"/>
</code>```

Implementation would ideally look something like:

```<code>protected async override void OnAppearing()
{
    x = readDeviceValue(0)
    if (x = 1)
    {
    OnToggledCutouts = true;
    }
    else
    {
    OnToggledCutouts = false;
    }
}
</code>```

How can I assign a boolean value to the TwoWay binding?

答:
The solution was to use the x:Name of the switch and not the IsToggled:</p>
```<code>protected async override void OnAppearing()
{
    x = readDeviceValue(0)
    if (x = 1)
    {
    ToggleCutouts.IsToggled = true;
    }
    else
    {
    ToggleCutouts.IsToggled = false;
    }
}
</code>```

Body:
Xamarin doesn't seem to natively support commanding a switch. In my app, apon a page opening, the app scans a device and looks at a certain value. Depending on whether or not the value is 0 or 1 I'd like to set the state of the switch accordingly.

I'd like it to determine and change state inside of:

protected async override void OnAppearing()

On Xaml page I have:

<Switch Grid.Column="3" Grid.Row="2" IsToggled ="{Binding OnToggledCutouts, Mode=TwoWay}" Toggled="OnToggledCutout" x:Name="ToggleCutouts"/>

Implementation would ideally look something like:

protected async override void OnAppearing()
{
    x = readDeviceValue(0)
    if (x = 1)
    {
    OnToggledCutouts = true;
    }
    else
    {
    OnToggledCutouts = false;
    }
}

How can I assign a boolean value to the TwoWay binding?

Body:
The solution was to use the x:Name of the switch and not the IsToggled:

protected async override void OnAppearing()
{
    x = readDeviceValue(0)
    if (x = 1)
    {
    ToggleCutouts.IsToggled = true;
    }
    else
    {
    ToggleCutouts.IsToggled = false;
    }
}


问:
How can i change the language of flutter app?
I want to make a dropdown item list of different languages and when user selects one of these app language should change. I don't know what logic to apply for changing language please help me.</p>

答: This is the topic of internationalization: https://docs.flutter.dev/development/accessibility-and-localization/internationalization</p>


问:
Not Able to Render Image in Spartacus
Product Image is not rendering in the custom Spartacus Component. Below is a code snippet of HTML Code.

I have checked the cx-media which takes the Image container and loads the image. But I was not able to figure out what is missing in my custom Spartacus storefront.

Also no request is triggered from spartacus to get the image. But the same happens on PDP. I am using the OOTB cx-media. Will this not call it internally?

<ng-container *ngIf="model$ | async as model">
<cx-product-list-item
  *ngFor="let product of model?.products"
  [product]="product"
  class="cx-product-search-list"
></cx-product-list-item>
</ng-container>```
</div>
</div>
</p>
<p>Response from the Backend</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>{
   "products" : [ {
      "averageRating" : 4.411764705882353,
      "baseOptions" : [ ],
      "code" : "358639",
      "configurable" : false,
      "images" : [ {
         "altText" : "DSC-N1",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNjE4MXxpbWFnZS9qcGVnfGltYWdlcy9oYjYvaDUzLzg3OTcyNjU0NjEyNzguanBnfGI2ZTBiOTI4ZTZlNWEwMWRiYzMwM2YzZTg3ODE5OTQ1ZDdmY2VkZGNiMTBlNjkyZmJmZDExYzIyOTNhZTBhNWM"
      }, {
         "altText" : "DSC-N1",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMjA3OHxpbWFnZS9qcGVnfGltYWdlcy9oODkvaGQxLzg3OTcyOTE3NDEyMTQuanBnfDE2NDc5MDE3MzNiMzIzYmYwOGRkN2YwZjg0MzVhMzRlNTM0ZTIyMWU3N2I4NmM3Mjg0NzUyODUzNTRjODkwZTg"
      }, {
         "altText" : "DSC-N1",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNDAxfGltYWdlL2pwZWd8aW1hZ2VzL2hlMi9oMzYvODc5NzMxODA4NjY4Ni5qcGd8YTIyNzcxNDBhMWQ3NGU0OWM5NDI0NGE1NGFmNGEzMDk1MjBhNTQ3NGRmMjVmMDBjNjFiN2RmZTY1NDhhMzFkNg"
      }, {
         "altText" : "DSC-N1",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxNDYyfGltYWdlL2pwZWd8aW1hZ2VzL2g0Yi9oMzIvODc5NzM0NDQzMjE1OC5qcGd8YTNkMGQ5MjBjOGQwNDJmNDNjZDE1NmI1ZjRjODYwOWZjNjkzOGZlZTNlODIyNjEzZjlkNmY0YzRhNDI2NjljNQ"
      } ],
      "manufacturer" : "Sony",
      "name" : "DSC-N1",
      "nameHtml" : "DSC-N1",
      "purchasable" : true,
      "summary" : "The Cyber-shot N1 offers 8.1 effective Megapixels with high sensitivity for reduced blur, a massive 3.0\"\" Clear Photo LCD Plus screen with touch-screen operation and a ZEISS 3x Optical Zoom.",
      "url" : "/Open-Catalogue/Cameras/Digital-Cameras/Digital-Compacts/DSC-N1/p/358639"
   }, {
      "averageRating" : 4.6,
      "baseOptions" : [ ],
      "code" : "479956",
      "configurable" : false,
      "images" : [ {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNTQ4M3xpbWFnZS9qcGVnfGltYWdlcy9oYmQvaDY5Lzg3OTcyNjc3NTUwMzguanBnfDVmMmY3ZTI5ZDI5ZDAxNjUxZmQxMjNkYWNhM2MzYjE3MDc3YTJmNmViOTI1M2IwOWQxYWExOTQwODA5NWU2YWQ"
      }, {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMDkwMHxpbWFnZS9qcGVnfGltYWdlcy9oNjEvaDcwLzg3OTcyOTQwMzQ5NzQuanBnfDk1MTBkMjU5YmRlZjNiNzIzM2IwZGYyZTdiYjZhNDVkOGQzNTdjODk1NDc0NmIxZDI4OWIwZTlhMDExMDUwYjQ"
      }, {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyMDQwfGltYWdlL2pwZWd8aW1hZ2VzL2gyMC9oODQvODc5NzMyMDM4MDQ0Ni5qcGd8OWRiOTk2YzY5MmUyOWNhNGIwM2ViNTI0YjBkMzBhMzllNDFkOWI0MWNiZmY3MDE1M2E3YjZkM2MzZmU2MzdjMA"
      }, {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMzQ3fGltYWdlL2pwZWd8aW1hZ2VzL2g3YS9oNjIvODc5NzM0NjcyNTkxOC5qcGd8YjczMDkxYzM0ZmY1NTc4MjEzOWU4Yzk3NGVlOWI5MjAxMTE4NTY1ZTBlNGIwY2UyNjRkZDhiNGE3ZmZkMWM0OA"
      } ],
      "manufacturer" : "Sony",
      "name" : "4GB Memory Stick Pro Duo + adapter",
      "nameHtml" : "4GB Memory Stick Pro Duo + adapter",
      "purchasable" : true,
      "summary" : "MSX-M4GSX - 4GB Memory Stick Pro Duo + adapter",
      "url" : "/Open-Catalogue/Data-storage/Flash-Memory/4GB-Memory-Stick-Pro-Duo-%2B-adapter/p/479956"
   }, {
      "averageRating" : 5.0,
      "baseOptions" : [ ],
      "code" : "1377492",
      "configurable" : false,
      "images" : [ {
         "altText" : "Micro Webcam",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMzI2N3xpbWFnZS9qcGVnfGltYWdlcy9oMDQvaGEzLzg3OTcyNTAxOTEzOTAuanBnfDFhNTIzZWY5M2E3NjMzZWQ5NGM4OGRlMDM0OGFjOGRmNDJiODVjMmJkM2YxMjZhZWI0NDkyMWFiZDMxOGJmOTA"
      }, {
         "altText" : "Micro Webcam",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wzMDk0NXxpbWFnZS9qcGVnfGltYWdlcy9oNWUvaDgxLzg3OTcyNzY1MzY4NjIuanBnfGM5M2ViZmQ2MmE4NjYwY2NlY2VjYzNhYmE1OGFhY2QxNThmMjE4YmMxYWRiMmU4ZDBhNzk2MjlmZDYyMzBiOGE"
      }, {
         "altText" : "Micro Webcam",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxNzgzfGltYWdlL2pwZWd8aW1hZ2VzL2g0OS9oNTUvODc5NzMwMjgxNjc5OC5qcGd8NjQ2MmM2MDgxZmUyNzU0YjJkMTY3NDM3MDJkNmFiYzQ4MzljMWFhN2QwMTVhYjliZjU0ZGMxNWZjNWViYjgzNg"
      }, {
         "altText" : "Micro Webcam",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMjMyfGltYWdlL2pwZWd8aW1hZ2VzL2g4My9oNTAvODc5NzMyOTE2MjI3MC5qcGd8MWMyZGY2Mzk4NGQ2ZjA5NGM3NWQ1ZDcwNjczNjRmMDYzZDY1YWUxZTY4ZTY3YTZjMDU3ZGIyNzMzMGFkM2RiNQ"
      } ],
      "manufacturer" : "Targus",
      "name" : "Micro Webcam",
      "nameHtml" : "Micro Webcam",
      "purchasable" : true,
      "url" : "/Open-Catalogue/Cameras/Webcams/Micro-Webcam/p/1377492"
   }, {
      "averageRating" : 2.607142857142857,
      "baseOptions" : [ ],
      "code" : "1986316",
      "configurable" : false,
      "images" : [ {
         "altText" : "LEGRIA HF S100",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNjU1MnxpbWFnZS9qcGVnfGltYWdlcy9oZDMvaGY5Lzg3OTcyNTU4Mjc0ODYuanBnfDZjMzRhZjBlN2JlMWZlM2UyZDJiNmM4OTRkODc0NTI3Y2QyNWZiOTgxZjFkMTkwMDc3YmJhNTQ4MDliM2M2NmU"
      }, {
         "altText" : "LEGRIA HF S100",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3w1OTg4NHxpbWFnZS9qcGVnfGltYWdlcy9oNzcvaDExLzg3OTcyODIxNzI5NTguanBnfDc0YmI4N2I2ZGRmMDYxMzYyZWU0MjJjM2UzYmU0ZTZkZmM3MDU0YjZlNTYxYmNkYjk5OGNjYzljNDY3MTcyMGE"
      }, {
         "altText" : "LEGRIA HF S100",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyMjMxfGltYWdlL2pwZWd8aW1hZ2VzL2hkNC9oODUvODc5NzMwODQ1Mjg5NC5qcGd8OWQyY2U0MTI5ODBhMzU4MmM4ZDE0NWQ2OGVhMzMwY2IzZDZlYjY5Mjc5NDM1YjVlY2FlOWIzNTQ4NDIzNjVmOQ"
      }, {
         "altText" : "LEGRIA HF S100",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxNDE2fGltYWdlL2pwZWd8aW1hZ2VzL2g5Ny9oMjAvODc5NzMzNDc5ODM2Ni5qcGd8OGI5YzQ0MzIzMDA1MGI4YzlmYTgwMzZkMmJlMGQ5M2M0YWExOTQ5OTViOGM1ZTVmNWIzZTFkMmFiNDdkNTFmZA"
      } ],
      "manufacturer" : "Canon",
      "name" : "LEGRIA HF S100",
      "nameHtml" : "LEGRIA HF S100",
      "purchasable" : true,
      "summary" : "LEGRIA HF S100 - SD/SDHC, 1/2.6\"\" CMOS, 8.59 megapixel, 6.4 - 64mm, 10x Optical, DIGIC DV III, 2.7\"\" LCD, 0.3 lux, 1/6 - 1/2000th sec., USB/HDMI",
      "url" : "/Open-Catalogue/Cameras/Hand-held-Camcorders/LEGRIA-HF-S100/p/1986316"
   } ]
}</code>```

Below is the Module

   import { ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BuyAgainComponent } from './buyAgain.component';
import { CmsConfig, provideDefaultConfig } from '@spartacus/core';
import { MediaModule, ProductListModule } from '@spartacus/storefront';

@NgModule({
  imports: [CommonModule,
    ProductListModule,
  MediaModule],
  providers: [
    provideDefaultConfig(<CmsConfig>{
      cmsComponents: {
        BuyAgainComponent: {
          component: BuyAgainComponent,
        },
      },
    }),
  ],
  declarations: [BuyAgainComponent],
  exports: [BuyAgainComponent],
})
export class BuyAgainModule {}```
</div>
</div>
</p>
<p>Below is the Configuration Module</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>@NgModule({
  declarations: [],
  imports: [
    LayoutConfigurationModule,
    ExtendServices,
    BuyAgainModule,
    HttpClientModule,
    BaseOccModule
  ],
  providers: [provideConfig(mediaConfig), ...defaultCmsContentProviders, provideConfig(<OccConfig>{
    backend: {
      occ: {
        baseUrl: 'https://localhost:9002/',
      }
    },</code>```

Here is the Inspect Element tool screenshot

Element tool screenshot

Result:

Product Image Not rendering

答:
I think the response is simple

TL;DR : Apply normalizer pipe as soon as you get the data:

```<code>constructor(private converterService: ConverterService) // inject the service
...

.pipe(this.converterService.pipeable(PRODUCT_NORMALIZER)) // pipe the received products
</code>```

Explanation: Spartacus usually needs to apply a normalize process over the data that comes from BE; in particular, for products, it normalizes the product data and the images; Inside product-image-normalizer.ts, it can be seen how it groups the images by imageType and format.  The ProductListItemComponent component that you are using (cx-product-list-item) is implemented like this:

```<code>  <cx-media
    class="cx-product-image"
    [container]="product.images?.PRIMARY"
    format="product"
    [alt]="product.summary"
  ></cx-media>
</code>```

And you may notice that for data that hasn't been normalized, product.images?.PRIMARY will be providing a null value for container input parameter, which prevents the image from being shown:

```<code>  protected create(): void {
    this.media = this.mediaService.getMedia(
      this.container,
      this.format,
      this.alt,
      this.role
    );
    if (!this.media?.src) {
      this.handleMissing();
    }
  }
</code>```

So, once the code for normalize the products is added, I'm pretty sure it will work. Please let me know how it was  Cheers!

Title: Not Able to Render Image in Spartacus

Body:
Product Image is not rendering in the custom Spartacus Component. Below is a code snippet of HTML Code.

I have checked the cx-media which takes the Image container and loads the image. But I was not able to figure out what is missing in my custom Spartacus storefront.

Also no request is triggered from spartacus to get the image. But the same happens on PDP. I am using the OOTB cx-media. Will this not call it internally?

<ng-container *ngIf="model$ | async as model">
<cx-product-list-item
  *ngFor="let product of model?.products"
  [product]="product"
  class="cx-product-search-list"
></cx-product-list-item>
</ng-container>

Response from the Backend

{
   "products" : [ {
      "averageRating" : 4.411764705882353,
      "baseOptions" : [ ],
      "code" : "358639",
      "configurable" : false,
      "images" : [ {
         "altText" : "DSC-N1",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNjE4MXxpbWFnZS9qcGVnfGltYWdlcy9oYjYvaDUzLzg3OTcyNjU0NjEyNzguanBnfGI2ZTBiOTI4ZTZlNWEwMWRiYzMwM2YzZTg3ODE5OTQ1ZDdmY2VkZGNiMTBlNjkyZmJmZDExYzIyOTNhZTBhNWM"
      }, {
         "altText" : "DSC-N1",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMjA3OHxpbWFnZS9qcGVnfGltYWdlcy9oODkvaGQxLzg3OTcyOTE3NDEyMTQuanBnfDE2NDc5MDE3MzNiMzIzYmYwOGRkN2YwZjg0MzVhMzRlNTM0ZTIyMWU3N2I4NmM3Mjg0NzUyODUzNTRjODkwZTg"
      }, {
         "altText" : "DSC-N1",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNDAxfGltYWdlL2pwZWd8aW1hZ2VzL2hlMi9oMzYvODc5NzMxODA4NjY4Ni5qcGd8YTIyNzcxNDBhMWQ3NGU0OWM5NDI0NGE1NGFmNGEzMDk1MjBhNTQ3NGRmMjVmMDBjNjFiN2RmZTY1NDhhMzFkNg"
      }, {
         "altText" : "DSC-N1",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxNDYyfGltYWdlL2pwZWd8aW1hZ2VzL2g0Yi9oMzIvODc5NzM0NDQzMjE1OC5qcGd8YTNkMGQ5MjBjOGQwNDJmNDNjZDE1NmI1ZjRjODYwOWZjNjkzOGZlZTNlODIyNjEzZjlkNmY0YzRhNDI2NjljNQ"
      } ],
      "manufacturer" : "Sony",
      "name" : "DSC-N1",
      "nameHtml" : "DSC-N1",
      "purchasable" : true,
      "summary" : "The Cyber-shot N1 offers 8.1 effective Megapixels with high sensitivity for reduced blur, a massive 3.0\"\" Clear Photo LCD Plus screen with touch-screen operation and a ZEISS 3x Optical Zoom.",
      "url" : "/Open-Catalogue/Cameras/Digital-Cameras/Digital-Compacts/DSC-N1/p/358639"
   }, {
      "averageRating" : 4.6,
      "baseOptions" : [ ],
      "code" : "479956",
      "configurable" : false,
      "images" : [ {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNTQ4M3xpbWFnZS9qcGVnfGltYWdlcy9oYmQvaDY5Lzg3OTcyNjc3NTUwMzguanBnfDVmMmY3ZTI5ZDI5ZDAxNjUxZmQxMjNkYWNhM2MzYjE3MDc3YTJmNmViOTI1M2IwOWQxYWExOTQwODA5NWU2YWQ"
      }, {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMDkwMHxpbWFnZS9qcGVnfGltYWdlcy9oNjEvaDcwLzg3OTcyOTQwMzQ5NzQuanBnfDk1MTBkMjU5YmRlZjNiNzIzM2IwZGYyZTdiYjZhNDVkOGQzNTdjODk1NDc0NmIxZDI4OWIwZTlhMDExMDUwYjQ"
      }, {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyMDQwfGltYWdlL2pwZWd8aW1hZ2VzL2gyMC9oODQvODc5NzMyMDM4MDQ0Ni5qcGd8OWRiOTk2YzY5MmUyOWNhNGIwM2ViNTI0YjBkMzBhMzllNDFkOWI0MWNiZmY3MDE1M2E3YjZkM2MzZmU2MzdjMA"
      }, {
         "altText" : "4GB Memory Stick Pro Duo + adapter",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMzQ3fGltYWdlL2pwZWd8aW1hZ2VzL2g3YS9oNjIvODc5NzM0NjcyNTkxOC5qcGd8YjczMDkxYzM0ZmY1NTc4MjEzOWU4Yzk3NGVlOWI5MjAxMTE4NTY1ZTBlNGIwY2UyNjRkZDhiNGE3ZmZkMWM0OA"
      } ],
      "manufacturer" : "Sony",
      "name" : "4GB Memory Stick Pro Duo + adapter",
      "nameHtml" : "4GB Memory Stick Pro Duo + adapter",
      "purchasable" : true,
      "summary" : "MSX-M4GSX - 4GB Memory Stick Pro Duo + adapter",
      "url" : "/Open-Catalogue/Data-storage/Flash-Memory/4GB-Memory-Stick-Pro-Duo-%2B-adapter/p/479956"
   }, {
      "averageRating" : 5.0,
      "baseOptions" : [ ],
      "code" : "1377492",
      "configurable" : false,
      "images" : [ {
         "altText" : "Micro Webcam",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMzI2N3xpbWFnZS9qcGVnfGltYWdlcy9oMDQvaGEzLzg3OTcyNTAxOTEzOTAuanBnfDFhNTIzZWY5M2E3NjMzZWQ5NGM4OGRlMDM0OGFjOGRmNDJiODVjMmJkM2YxMjZhZWI0NDkyMWFiZDMxOGJmOTA"
      }, {
         "altText" : "Micro Webcam",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wzMDk0NXxpbWFnZS9qcGVnfGltYWdlcy9oNWUvaDgxLzg3OTcyNzY1MzY4NjIuanBnfGM5M2ViZmQ2MmE4NjYwY2NlY2VjYzNhYmE1OGFhY2QxNThmMjE4YmMxYWRiMmU4ZDBhNzk2MjlmZDYyMzBiOGE"
      }, {
         "altText" : "Micro Webcam",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxNzgzfGltYWdlL2pwZWd8aW1hZ2VzL2g0OS9oNTUvODc5NzMwMjgxNjc5OC5qcGd8NjQ2MmM2MDgxZmUyNzU0YjJkMTY3NDM3MDJkNmFiYzQ4MzljMWFhN2QwMTVhYjliZjU0ZGMxNWZjNWViYjgzNg"
      }, {
         "altText" : "Micro Webcam",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxMjMyfGltYWdlL2pwZWd8aW1hZ2VzL2g4My9oNTAvODc5NzMyOTE2MjI3MC5qcGd8MWMyZGY2Mzk4NGQ2ZjA5NGM3NWQ1ZDcwNjczNjRmMDYzZDY1YWUxZTY4ZTY3YTZjMDU3ZGIyNzMzMGFkM2RiNQ"
      } ],
      "manufacturer" : "Targus",
      "name" : "Micro Webcam",
      "nameHtml" : "Micro Webcam",
      "purchasable" : true,
      "url" : "/Open-Catalogue/Cameras/Webcams/Micro-Webcam/p/1377492"
   }, {
      "averageRating" : 2.607142857142857,
      "baseOptions" : [ ],
      "code" : "1986316",
      "configurable" : false,
      "images" : [ {
         "altText" : "LEGRIA HF S100",
         "format" : "zoom",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyNjU1MnxpbWFnZS9qcGVnfGltYWdlcy9oZDMvaGY5Lzg3OTcyNTU4Mjc0ODYuanBnfDZjMzRhZjBlN2JlMWZlM2UyZDJiNmM4OTRkODc0NTI3Y2QyNWZiOTgxZjFkMTkwMDc3YmJhNTQ4MDliM2M2NmU"
      }, {
         "altText" : "LEGRIA HF S100",
         "format" : "product",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3w1OTg4NHxpbWFnZS9qcGVnfGltYWdlcy9oNzcvaDExLzg3OTcyODIxNzI5NTguanBnfDc0YmI4N2I2ZGRmMDYxMzYyZWU0MjJjM2UzYmU0ZTZkZmM3MDU0YjZlNTYxYmNkYjk5OGNjYzljNDY3MTcyMGE"
      }, {
         "altText" : "LEGRIA HF S100",
         "format" : "thumbnail",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wyMjMxfGltYWdlL2pwZWd8aW1hZ2VzL2hkNC9oODUvODc5NzMwODQ1Mjg5NC5qcGd8OWQyY2U0MTI5ODBhMzU4MmM4ZDE0NWQ2OGVhMzMwY2IzZDZlYjY5Mjc5NDM1YjVlY2FlOWIzNTQ4NDIzNjVmOQ"
      }, {
         "altText" : "LEGRIA HF S100",
         "format" : "cartIcon",
         "imageType" : "PRIMARY",
         "url" : "/medias/?context=bWFzdGVyfGltYWdlc3wxNDE2fGltYWdlL2pwZWd8aW1hZ2VzL2g5Ny9oMjAvODc5NzMzNDc5ODM2Ni5qcGd8OGI5YzQ0MzIzMDA1MGI4YzlmYTgwMzZkMmJlMGQ5M2M0YWExOTQ5OTViOGM1ZTVmNWIzZTFkMmFiNDdkNTFmZA"
      } ],
      "manufacturer" : "Canon",
      "name" : "LEGRIA HF S100",
      "nameHtml" : "LEGRIA HF S100",
      "purchasable" : true,
      "summary" : "LEGRIA HF S100 - SD/SDHC, 1/2.6\"\" CMOS, 8.59 megapixel, 6.4 - 64mm, 10x Optical, DIGIC DV III, 2.7\"\" LCD, 0.3 lux, 1/6 - 1/2000th sec., USB/HDMI",
      "url" : "/Open-Catalogue/Cameras/Hand-held-Camcorders/LEGRIA-HF-S100/p/1986316"
   } ]
}

Below is the Module

   import { ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BuyAgainComponent } from './buyAgain.component';
import { CmsConfig, provideDefaultConfig } from '@spartacus/core';
import { MediaModule, ProductListModule } from '@spartacus/storefront';

@NgModule({
  imports: [CommonModule,
    ProductListModule,
  MediaModule],
  providers: [
    provideDefaultConfig(<CmsConfig>{
      cmsComponents: {
        BuyAgainComponent: {
          component: BuyAgainComponent,
        },
      },
    }),
  ],
  declarations: [BuyAgainComponent],
  exports: [BuyAgainComponent],
})
export class BuyAgainModule {}

Below is the Configuration Module

@NgModule({
  declarations: [],
  imports: [
    LayoutConfigurationModule,
    ExtendServices,
    BuyAgainModule,
    HttpClientModule,
    BaseOccModule
  ],
  providers: [provideConfig(mediaConfig), ...defaultCmsContentProviders, provideConfig(<OccConfig>{
    backend: {
      occ: {
        baseUrl: 'https://localhost:9002/',
      }
    },

Here is the Inspect Element tool screenshot

Element tool screenshot

Result:

Product Image Not rendering

Body:
I think the response is simple

TL;DR : Apply normalizer pipe as soon as you get the data:

constructor(private converterService: ConverterService) // inject the service
...

.pipe(this.converterService.pipeable(PRODUCT_NORMALIZER)) // pipe the received products

Explanation: Spartacus usually needs to apply a normalize process over the data that comes from BE; in particular, for products, it normalizes the product data and the images; Inside product-image-normalizer.ts, it can be seen how it groups the images by imageType and format.  The ProductListItemComponent component that you are using (cx-product-list-item) is implemented like this:

  <cx-media
    class="cx-product-image"
    [container]="product.images?.PRIMARY"
    format="product"
    [alt]="product.summary"
  ></cx-media>

And you may notice that for data that hasn't been normalized, product.images?.PRIMARY will be providing a null value for container input parameter, which prevents the image from being shown:

  protected create(): void {
    this.media = this.mediaService.getMedia(
      this.container,
      this.format,
      this.alt,
      this.role
    );
    if (!this.media?.src) {
      this.handleMissing();
    }
  }

So, once the code for normalize the products is added, I'm pretty sure it will work. Please let me know how it was  Cheers!


问:
Android 12 splash screen conditional start screen
I went through the documentation on the splash screen for Android 12 and also on migrating existing splash screen but it doesn't mention clearly how to select the start screen based on the condition.

Specifically, I had added the check if the user is signed in like this previously:

```<code>class SplashScreenActivity: AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash_screen)

        if(viewModel.isUserSignedIn()) {
            navigateToMain()
        } else {
            navigateToAuth()
        }
    }
}
</code>```

where the SplashScreenActivity was marked as the default launch activity. When I keep it like this, Android studio gives a warning - The application should not provide its own launch screen.

I modified it as per the guide and removed setContentView from the activity and called installSplashScreen.

```<code>class SplashScreenActivity: AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        installSplashScreen()

        if(viewModel.isUserSignedIn()) {
            navigateToMain()
        } else {
            navigateToAuth()
        }
    }
}
</code>```

When I run on the emulator, it seems to be working as expected but the Android Studio continues to give the same warning.

Is this the right way to migrate to the Android 12 splash screen, if yes, why is the error on Android Studio still showing?
Also, do we need to keep the activity as the default launcher or is there a change required there?

答:
It's because you're creating an activity just for the SplashScreen. In the documentation, they state that the SplashScreen should be called in MainActivity here

Basically, you either need to set your splashScreen in the MainActivity or do this after migrating:

After you've migrated to the new splash screen experience for Android 12 and higher, your custom splash screen Activity is still
left over, so you’ll need to choose what to do with it. You have the
following options:

Keep the custom activity, but prevent it from displaying

Keep the custom activity for branding reasons

Remove the custom activity, and adapt your app as needed

Body:
I went through the documentation on the splash screen for Android 12 and also on migrating existing splash screen but it doesn't mention clearly how to select the start screen based on the condition.

Specifically, I had added the check if the user is signed in like this previously:

class SplashScreenActivity: AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash_screen)

        if(viewModel.isUserSignedIn()) {
            navigateToMain()
        } else {
            navigateToAuth()
        }
    }
}

where the SplashScreenActivity was marked as the default launch activity. When I keep it like this, Android studio gives a warning - The application should not provide its own launch screen.

I modified it as per the guide and removed setContentView from the activity and called installSplashScreen.

class SplashScreenActivity: AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        installSplashScreen()

        if(viewModel.isUserSignedIn()) {
            navigateToMain()
        } else {
            navigateToAuth()
        }
    }
}

When I run on the emulator, it seems to be working as expected but the Android Studio continues to give the same warning.

Is this the right way to migrate to the Android 12 splash screen, if yes, why is the error on Android Studio still showing?
Also, do we need to keep the activity as the default launcher or is there a change required there?


问:
How to mitigate useless React renders when large state is present but only one changes?
I have a search query component. User types query, clicks run and executes it. However, due to how state is organized, it causes excessive re renders. Following is a simplification of it. This organization of the code feels natural to me. QueryEditor is normally a complex editor, hence it stores its own value. Similar for query results. I got the value of it on each change, updated the query in the parent component. However this causes all HTML elements in the parent component to re-render even though their state does not change.

First of all, not being very familiar with the concepts;

Is this expected behavior? What I've done might not be ideal, but causing every DOM elment to rerenders because parent state changed feels unncesseary to me. Or maybe I'm doing something wrong.

How would this be improved? Obviously thing to improve is not get every change as a callback, but I did not find a good way to call a method of child component to getValue()     from a parent component.

Link if you want: https://codesandbox.io/s/purple-architecture-5kpx5?file=/src/App.tsx You can clearly see the performance impact with React DevTools and see the render time increases with the number of elements even the elements did not change but the query text changes.

function App() {
  console.log("Re-render?");

  const [name, setName] = useState("mustafa");
  const [query, setQuery] = useState("");
  const [data, setData] = useState<number[]>([]);

  const runQuery = () => {
    console.log("using query...", query);
    setData([...Array(data.length + 1000).keys()]);
  };

  return (

Hello {name}

Please enter your query

      <QueryEditor
        onChange={(e) => {
          setQuery(e.target.value);
        }}
      />

      <button onClick={runQuery}>Run Query</button>

Results

      {data.length > 0 &&
There are {data.length} results
}
      {data.length > 0 && <DataResults data={data} />}

  );
}

interface EditorProps {
  onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
}

function QueryEditor({ onChange }: EditorProps) {
  return <textarea onChange={onChange} />;
}

function DataResults({ data }: { data: number[] }) {
  return (

        {data.map((a) => (

Item {a}

        ))}

  );
}

```

答:
you can't change the parent's behaviour of re-rendering. That is the way react works, when the children has to re-render, then the parent has to re-render the child, thus being called again. Have a look at the docs to understand the logic behind re-rendering.

What you can do in this case, is to memoized the siblings that has huge data.

So if I do this:

```<code>const DataResultsMemoized = React.memo(DataResults);
</code>```

Then use it in the parent:

```<code>      {data.length > 0 && <DataResultsMemoized data={data} />}
</code>```

Then your sibling won't re-render every time you type in the textbox.

Here's code sandbox example, check that the console.log in the children doesn't go again when you type

Body:
you can't change the parent's behaviour of re-rendering. That is the way react works, when the children has to re-render, then the parent has to re-render the child, thus being called again. Have a look at the docs to understand the logic behind re-rendering.

What you can do in this case, is to memoized the siblings that has huge data.

So if I do this:

const DataResultsMemoized = React.memo(DataResults);

Then use it in the parent:

      {data.length > 0 && <DataResultsMemoized data={data} />}

Then your sibling won't re-render every time you type in the textbox.

Here's code sandbox example, check that the console.log in the children doesn't go again when you type


问:
check state of a component using react testing library
I have triggered a change in component using react testing library and I want to check the corresponding change in the state of the component.
Is it possible to check the state of the component</p>

答:
Disclaimer: I agree that using inner state of component for testing isn't nice practice. But there are sometimes situations where you are forced to, otherwise use case would not be tested at all.

Example: You want to change position of cursor in draft-js. That is impossible via browser/JSDOM events. You need to use dradt-js API for that. draft-js EditorState is stored as react state within the component. So in order to test this test case you are forced to manipulate inner state of the component.

Option is to use Enzyme APIs state and setState. Yes that means using Enzyme (for such exceptional cases) and react-testing-library in one project

But in my test I was facing also Enzyme issue, which is not worth mentioning, so I ended up doing such nasty trick. In production component itself, I stored state and setter into global variables. I named them so that it is obviously not good idea to use them in production:

```<code>export let innerStateFOR_TESTING;
export let setInnerStateFOR_TESTING;

const Component = () => {
    const [innerState, setInnerState] = React.useState(null);
    innerStateFOR_TESTING = innerState;
    setInnerStateFOR_TESTING = setInnerState;

    ...
}
</code>```

In test I can than render the component, which would fill in those global variables. Than I can manipulate/check inner state for testing purposes.

I wish there would be option in react-testing-library. It can be discouraged practice, but if your other option is not test certain scenario, it would be available.

Body:
Disclaimer: I agree that using inner state of component for testing isn't nice practice. But there are sometimes situations where you are forced to, otherwise use case would not be tested at all.

Example: You want to change position of cursor in draft-js. That is impossible via browser/JSDOM events. You need to use dradt-js API for that. draft-js EditorState is stored as react state within the component. So in order to test this test case you are forced to manipulate inner state of the component.

Option is to use Enzyme APIs state and setState. Yes that means using Enzyme (for such exceptional cases) and react-testing-library in one project

But in my test I was facing also Enzyme issue, which is not worth mentioning, so I ended up doing such nasty trick. In production component itself, I stored state and setter into global variables. I named them so that it is obviously not good idea to use them in production:

export let innerStateFOR_TESTING;
export let setInnerStateFOR_TESTING;

const Component = () => {
    const [innerState, setInnerState] = React.useState(null);
    innerStateFOR_TESTING = innerState;
    setInnerStateFOR_TESTING = setInnerState;

    ...
}

In test I can than render the component, which would fill in those global variables. Than I can manipulate/check inner state for testing purposes.

I wish there would be option in react-testing-library. It can be discouraged practice, but if your other option is not test certain scenario, it would be available.


问:
Failed to resolve: com.github.PhilJay:MPAndroidChart:v2.1.4
I'm using MPAndroidChart library in android studio. But when I'm trying to sync gradle I get an error as shown in below image.

Gradle text is here to compile MPAndroidChart library.

```<code>compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'
</code>```

How can I resolve this problem?

答:
As the Android studio is updated so you have to control your dependency form your setting.app

```<code>dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'https://jitpack.io' }
    }
}
</code>```

Kindly place this line the respiratory

```<code>maven { url 'https://jitpack.io' } //as i have done above
</code>```

Body:
I'm using MPAndroidChart library in android studio. But when I'm trying to sync gradle I get an error as shown in below image.

Gradle text is here to compile MPAndroidChart library.

compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'

How can I resolve this problem?

Body:
As the Android studio is updated so you have to control your dependency form your setting.app

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url 'https://jitpack.io' }
    }
}

Kindly place this line the respiratory

maven { url 'https://jitpack.io' } //as i have done above


问:
How to parse numbers in strings and sort them?
I have an array of strings and I need to sort them first numerically if it contains a number and then if not sort alphanumerically.

Example:

```<code>const array = ["test 3","test 1","some test","another test","test 2"];
</code>```

Expected result: test 1, test 2 , test 3, another test, some test

Preference for es6 solution.

答:
You can use this function :</p>
```<code>array.sort((a, b) => a.charCodeAt(a.length - 1) - b.charCodeAt(b.length - 1));
</code>```

Body:
I have an array of strings and I need to sort them first numerically if it contains a number and then if not sort alphanumerically.

Example:

const array = ["test 3","test 1","some test","another test","test 2"];

Expected result: test 1, test 2 , test 3, another test, some test

Preference for es6 solution.

Body:
You can use this function :

array.sort((a, b) => a.charCodeAt(a.length - 1) - b.charCodeAt(b.length - 1));


问:
JavaScript(React)- Uncaught TypeError: Cannot read properties of undefined (reading 'style')
I am working in a project using React Js. When I wrote this, Syntax:  movieRef.current.style.transform = translateX(210px); it's not working. It shows an error- can't read 'style'. How can I solve this problem. I have attached my codes here.

import React, { useState, useRef } from "react";
import { useGetMoviesQuery } from "../../services/movieApi";
import SingleMovie from "../SingleMovie/SingleMovie";
import "./MovieRow.scss";
import "../SingleMovie/SingleMovie.scss";
import { MdArrowForwardIos, MdArrowBackIos } from "react-icons/md";

// const MovieRow = ({title}) => {codes}
const MovieRow = (props) => {
  const { title, fetchURI } = props;
  const { data, isLoading } = useGetMoviesQuery(fetchURI);
  const movieRef = useRef();
  // console.log("data:", data);

  if (isLoading) {
    return (

Loading...

    );
  }
  const handleClick = (direction) => {
    if (direction === "left") {
      movieRef.current.style.transform = `translateX(210px)`;
    }
  };
  return (
    <>

{title}

          <MdArrowForwardIos
            className="slider right-arrow"
            onClick={() => handleClick("right")}
          />

            {data?.results.map((movie, index) => (
              <SingleMovie key={movie?.id} singleMovie={movie} index={index} />
            ))}

          <MdArrowBackIos
            className="slider left-arrow"
            onClick={handleClick("left")}
          />

    </>
  );
};

export default MovieRow;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>//MovieRow.scss file

h1 {
  font-family: sans-serif;
  font-size: 100%;
  color: white;
}
// non-global css
.movie-row-container {
  margin-top: 25px;
  margin-left: 22px;
  .wrapper {
    position: relative;
    .slider {
      height: 100%;
      width: 70px;
      background-color: rgba(12, 42, 214, 0.438);
      color: white;
      position: absolute;
      z-index: 99;
      margin: 0 auto;
      cursor: pointer;

      &.right-arrow {
        right: 0;
      }

      &.left-arrow {
        left: 0;
      }
    }
    .movie-row-block {
      display: flex;
      overflow-x: scroll;
      overflow-y: hidden;
      transform: translateX(210px);
    }
  }
  .movie-row-block::-webkit-scrollbar {
    display: none;
  }
}</code>```

答:
This part is firing infinitely even before the first render, that's why you'll get undefined on style:

```<code>          <MdArrowBackIos
            className="slider left-arrow"
            onClick={handleClick("left")}
          />
</code>```

Change it to this:

```<code>           <MdArrowBackIos
             className="slider left-arrow"
             onClick={handleClick.bind(undefined, "left")}
           />
</code>```

Body:
I am working in a project using React Js. When I wrote this, Syntax:  movieRef.current.style.transform = translateX(210px); it's not working. It shows an error- can't read 'style'. How can I solve this problem. I have attached my codes here.

import React, { useState, useRef } from "react";
import { useGetMoviesQuery } from "../../services/movieApi";
import SingleMovie from "../SingleMovie/SingleMovie";
import "./MovieRow.scss";
import "../SingleMovie/SingleMovie.scss";
import { MdArrowForwardIos, MdArrowBackIos } from "react-icons/md";

// const MovieRow = ({title}) => {codes}
const MovieRow = (props) => {
  const { title, fetchURI } = props;
  const { data, isLoading } = useGetMoviesQuery(fetchURI);
  const movieRef = useRef();
  // console.log("data:", data);

  if (isLoading) {
    return (

Loading...

    );
  }
  const handleClick = (direction) => {
    if (direction === "left") {
      movieRef.current.style.transform = `translateX(210px)`;
    }
  };
  return (
    <>

{title}

          <MdArrowForwardIos
            className="slider right-arrow"
            onClick={() => handleClick("right")}
          />

            {data?.results.map((movie, index) => (
              <SingleMovie key={movie?.id} singleMovie={movie} index={index} />
            ))}

          <MdArrowBackIos
            className="slider left-arrow"
            onClick={handleClick("left")}
          />

    </>
  );
};

export default MovieRow;

//MovieRow.scss file

h1 {
  font-family: sans-serif;
  font-size: 100%;
  color: white;
}
// non-global css
.movie-row-container {
  margin-top: 25px;
  margin-left: 22px;
  .wrapper {
    position: relative;
    .slider {
      height: 100%;
      width: 70px;
      background-color: rgba(12, 42, 214, 0.438);
      color: white;
      position: absolute;
      z-index: 99;
      margin: 0 auto;
      cursor: pointer;

      &.right-arrow {
        right: 0;
      }

      &.left-arrow {
        left: 0;
      }
    }
    .movie-row-block {
      display: flex;
      overflow-x: scroll;
      overflow-y: hidden;
      transform: translateX(210px);
    }
  }
  .movie-row-block::-webkit-scrollbar {
    display: none;
  }
}

Body:
This part is firing infinitely even before the first render, that's why you'll get undefined on style:

          <MdArrowBackIos
            className="slider left-arrow"
            onClick={handleClick("left")}
          />

Change it to this:

           <MdArrowBackIos
             className="slider left-arrow"
             onClick={handleClick.bind(undefined, "left")}
           />